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:

package
{
    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);
            addChild(tf);
        }
    }
}

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:

2 comments so far

  1. edzis July 12, 2010 13:56

    The answer is embedAsCFF=”false”

  2. Jozef Chúťka July 12, 2010 14:01

    thnx for quick reply edzis, but also no luck with embedAsCFF=”false”, I realised that must be some kind of flash player bug because I was able to use it this way in past and today suddenly it stopped working 🙁

Leave a comment

Please be polite and on topic. Your e-mail will never be published.