zakdances
zakdances

Reputation: 23685

Embedded font makes TextField invisible

I don't understand why my text field doesn't show up when I use an embedded font:

[Embed(source="../resources/fonts/h55.ttf", fontName="h55", mimeType="application/x-font", unicodeRange =
'U+0020-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E')]
public static const h55embed:Class;

public function animate():void
{
        var myformat:TextFormat = new TextFormat('h55embed',24);
        myformat.color = 0xffffff;
        myformat.align="center";


        var text:TextField = new TextField();

        text.embedFonts = true; // very important to set
        text.text = 'my text';
        text.setTextFormat(myformat);

        text.autoSize = TextFieldAutoSize.LEFT;
        text.x = (this.stage.width/2) - (text.width/2);
        text.y = this.stage.height - text.height - 20;



        this.stage.addChild(text);


}

What is wrong with this code?

Upvotes: 0

Views: 400

Answers (1)

Barış Uşaklı
Barış Uşaklı

Reputation: 13532

Don't you need to use the same fontName when you create the TextFormat?

var myformat:TextFormat = new TextFormat('h55',24);

Also try the embedAsCFF in your embed meta tag

This works for me in my application :

[Embed(source = "../../../../Knights Quest.ttf", fontName="Knights", mimeType = 'application/x-font', embedAsCFF = "false")]
public static const KNIGHTS:Class;

Upvotes: 1

Related Questions