Fonts not working on compiling to flash any tip?

34 views
Skip to first unread message

Thiago Sabin

unread,
Oct 15, 2015, 12:53:07 PM10/15/15
to Haxe
Hello felas so i'm using an example i got and here is how im going:

var font = Assets.getFont("fonts/FreebooterUpdated.ttf");
var myFormat = new TextFormat (font.fontName, 22, 0xFFFFFF, null);
mainTitle.text = "Crie sua conta";
mainTitle.width = 500;
mainTitle.mouseEnabled = false;
mainTitle.defaultTextFormat = new TextFormat (font.fontName, 32, 0xFFFFFF, null);
mainTitle.embedFonts = true;
mainTitle.x = 519;
mainTitle.y = 20;
this.addChild(mainTitle);

It's working fine compiling with html5 and windows but flash is not getting the font and i don't know why any help?

Tom

unread,
Oct 15, 2015, 5:39:49 PM10/15/15
to Haxe
Hi!

I have faced the same problem before.
The flash platform font name is not the same...
If I remember correctly, in flash you need to use:
font.fontName.split("/").pop(); // font name without the path

At your code:
#if flash
mainTitle
.defaultTextFormat = new TextFormat (font.fontName.split("/").pop(), 32, 0xFFFFFF, null);
else

mainTitle
.defaultTextFormat = new TextFormat (font.fontName, 32, 0xFFFFFF, null);
#end

I hope, this help.

ps.: If this is not enough, please trace all registered font and font name, and all font.fontName from the Assets,
to compare them.
Reply all
Reply to author
Forward
0 new messages