• Fonts are graphical resources that can be accessed with a call to ej.microui.display.Font.getFont(). To be displayed, these fonts have to be converted at build-time from their source format to the display raw format by the font generator tool.
  • Fonts, just like images, must be declared in a *.fonts.list file.

Creating a font

  • To create a font, go to the package you want to store your fonts in, usually Resources> fonts.

  • Then Right-Click > New > Other> MicroEJ > MicroEJ Font:

  • Then, type the name of the font:

  • Click on Finish, the following window opens:



    It is important to have the font that you want already installed on your system.

  • To import characters from a system font, click on Import… and the following opens:

  • Click on Next and then select the font to use as shown below:



    If using a latin based alphabet, just leave the settings as they are and click on Finish, don’t forget to adjust the height and baseline of the font.

  • Click Finish and save the file. The font is imported in the .ejf file.

  • Then just add the font to a myapp.fonts.list file in the src/main/resources source folder of your application:

  • More info in the Fonts section.

Adding the Font to a Label

To add the font, choose the font in the StyleSheet:

public static void main(String[] args) {
   Desktop desktop = new Desktop();
   Flow flow = new Flow(LayoutOrientation.VERTICAL);
   Label label = new Label("Hello World");
   Font font = Font.getFont("/fonts/NewFont.ejf");
   CascadingStylesheet css = new CascadingStylesheet();
   EditableStyle style = css.getSelectorStyle(new ClassSelector(BUTTON));


Don’t forget to set the stylesheet to the desktop.


Next step: Scroll List