Unable to Embed Font When Targeting Flash Player 10.1

I am just so stuck on this one. Is anyone able to embed font and use it in TextField when targeting Flash player 10.1 using flex 4.1 SDK? My code is very simple:

    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
    public class Test1 extends Sprite
        [Embed(source="arial.ttf", fontName="Arial", mimeType='application/x-font')]
        public static const FONT_ARIAL:Class;
        public function Test1()
            var tf:TextField = new TextField();
            tf.text = "Hallo";
            tf.embedFonts = true;
            tf.defaultTextFormat = new TextFormat("Arial", 10);

font file (.ttf) can be downloaded here. When I try to export the movie I see nothing but white. Actualy it seems like no matter what sdk nor flash player version I target, it still does not render text 🙁 what is going on flashplayer?

Mistery solved!, you have to set defaultTextFormat before text. Credits goes to Martin.

Where to go from here:

Embedding fonts bold vs. black


Embedding fonts into flex app can be a tricky things. Lets suggest you need to embed Arial font in both bold and black style. When you open some desktop application using local font list, you notice Arial font family and under this option there is a list of styles. There is a bold and black style in one list so one would guess it is the same thing setting. Well, it is not. When it comes to embedding into flex, the code varies much more…

Read the rest of this entry »