7 Replies Latest reply: Nov 15, 2010 7:40 AM by MatteoLegittimo RSS

    Embedding Font AS3 w/ Flash Builder 4 OSX


      I have written a simple label class that works fine when not pointing to my embedded font. When using the embedded it fails to render the text on screen.



      package com.components.misc
           import flash.display.Sprite;
           import flash.text.AntiAliasType;
           import flash.text.TextField;
           import flash.text.TextFieldAutoSize;
           import flash.text.TextFormat;
           public class Label extends Sprite
                public function Label(str:String, color:int = 0x000000, size:int = 22, embedded:Boolean = false, font:String = "marker")
                     trace ("string : "+str+", color : "+color+", size : "+size+", embedded : "+embedded+", font : "+font)
                     var format:TextFormat = new TextFormat();
                     if (embedded) format.font = font;
                     format.color = color;
                     format.size = size;
                     var label:TextField         = new TextField();
                     label.embedFonts            = embedded;
                     label.autoSize              = TextFieldAutoSize.CENTER;
                     label.antiAliasType         = AntiAliasType.ADVANCED;
                     label.defaultTextFormat     = format;
                     label.text                  = str;


      Method used to embed font

      package com.managers
           import flash.display.Bitmap;
           public class AssetManager {
                // Embedded Font Does Not Display - ERROR
                [Embed(source='assets/MarkerFelt.ttf', fontName="Marker", fontFamily="Marker", mimeType="application/x-font-truetype")]
                public static const FONT_MARKER:String;
                public static const IMAGE_LOGO:Class;


      Usage from base class

      var l:Label = new Label("Come On, Work Already", 0xff0000, 42, true, AssetManager.FONT_MARKER);