Can't load font

Hello! I’m experiencing some issues when trying to load a font from the Assets directory. Instead of using the font I provide it the app uses the custom font.

    var titleFormat = new TextFormat();
    titleFormat.align = TextFormatAlign.CENTER;
    titleFormat.size = / 4);
    titleFormat.font = Assets.getFont("fonts/myfont.otf").fontName;
    titleFormat.color = Colors.WHITE;

    var title = new TextField();
    title.text = "Zett";
    title.defaultTextFormat = titleFormat;
    title.width = Lib.current.stage.stageWidth;
    title.height = titleFormat.size;
    title.x = 0;
    title.y = Lib.current.stage.stageHeight / 4;


Try title.embedFonts = true;

Still not working…

Try to load .ttf font, not .otf font.

Simple rename will not work, you must put real ttf font.
You can use fontforge to convert any font to ttf -

When compiling project openfl will convert .ttf into all other font formats. And for html5 target openfl is smart enough to load appropriate font format (ttf, otf, svn or woff), but you must load .ttf from assets.

I converted the font to .ttf but the problem is the same.

I think there is a problem with Assets.getFont(“fonts/Ikaros.ttf”).fontName because if I trace its value I get null. Anyway I solved the problem by simply replacing Assets.getFont(“fonts/Ikaros.ttf”).fontName with “fonts/Ikaros.ttf”.

This way I can even use the .otf font.

A while back, we made changes to make fonts work with the font name. Perhaps something happens with this specific font that prevents it from reading the font name properly. Is this a free font we could use to test?

Yes, you can get it from here: