Apply a font for unrecognized character

#1

I have a question in relation to the add of do’s.
I generated a font with the MicroEj Font and it does it automatically applied to the button’s label but not to the drawString as you did in the hello example is what you can guide me on how I can apply to drawString

#2

Hi @ghassane_elkebir,

To use a custom font, you need to:

  1. Add it to your resource folder
  2. Add it to your [prefix].fonts.list

Then you can use it.
Only using MicroUI, you can set it like this:

g.setFont(Font.getFont("myFontPrefix", myFontHeight, Font.STYLE_PLAIN));
g.drawString("MyString", 0, 0, GraphicsContext.TOP | GraphicsContext.LEFT);

You can see an example of the usage in our Example-Standalone-Foundation-Libraries

If you are using style you could use the style helper to get the font linked to the style:

g.setFont(StyleHelper.getFont(style));
g.drawString("MyString", 0, 0, GraphicsContext.TOP | GraphicsContext.LEFT);

Regards,