Highlighted

Embedding Font AS3 w/ Flash Builder 4 OSX

New Here ,
Apr 09, 2010

Copy link to clipboard

Copied

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.

Label.as

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")

          {

               super();

               

               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;

               addChild(label);

          }

     }

}

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;

          

          [Embed(source="assets/logo.png")]

          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);

addChild(l);

TOPICS
ActionScript

Views

7.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Embedding Font AS3 w/ Flash Builder 4 OSX

New Here ,
Apr 09, 2010

Copy link to clipboard

Copied

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.

Label.as

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")

          {

               super();

               

               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;

               addChild(label);

          }

     }

}

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;

          

          [Embed(source="assets/logo.png")]

          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);

addChild(l);

TOPICS
ActionScript

Views

7.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 09, 2010 0
New Here ,
Apr 09, 2010

Copy link to clipboard

Copied

I have also tried to set the embedAsCFF to false in the embed tag and also set an additional flag in the application compiler settings which is -managers flash.fonts.AFEFontManager. And neither of these changes worked.

Updated Classes

package com.managers

{

     import flash.display.Bitmap;

     public class AssetManager {

          // Embedded Font Does Not Display - ERROR

          [Embed(source='assets/MarkerFelt.ttf', fontFamily="Marker", fontName="Marker", embedAsCFF=false, mimeType="application/x-font-truetype")]

          public static const FONT_MARKER:String;

          

          [Embed(source="assets/logo.png")]

          public static const IMAGE_LOGO:Class;

     }

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 09, 2010 0
New Here ,
Apr 10, 2010

Copy link to clipboard

Copied

I am still unable to successfully embed a font using this method. Has anyone successfuly been able to do so with flash builder? If so, please post your method.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 10, 2010 0
Contributor ,
Apr 12, 2010

Copy link to clipboard

Copied

Hi!

I have tried this as a main class in ActionSrtipt project and it workes fine.

package
{
    import flash.display.MovieClip;
    import flash.text.*;
   
    public class QuickTest extends MovieClip
    {

        // Embed the font Verdana
        [Embed(source="c:/windows/fonts/verdana.ttf", fontFamily="Verdana")]
        private var verdana:Class;
       
        public function QuickTest ()
        {
            // Set the font with a TextFormat object
            var format:TextFormat = new TextFormat( );
            format.font = "Verdana";
            format.size = 56;
           
            var t:TextField = new TextField( );
            t.embedFonts = true;
            // Format text using the font Verdana
            t.defaultTextFormat = format;
            t.text = "hello world";
            addChild(t);
        }
    }
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 12, 2010 0
New Here ,
Aug 13, 2010

Copy link to clipboard

Copied

Did you solve this? I am having the same problem.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 13, 2010 0
Participant ,
Nov 15, 2010

Copy link to clipboard

Copied

I have same problem to!

Fails to print text on screen!

I think there is some setting in flash builder!

Help!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 15, 2010 0
Participant ,
Nov 15, 2010

Copy link to clipboard

Copied

hey!

I just did it!

U have to add embedAsCFF="false"

like for example this:

[

Embed(source="c:/windows/fonts/verdana.ttf", fontFamily="Verdana", embedAsCFF="false")]

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 15, 2010 0
Participant ,
Nov 15, 2010

Copy link to clipboard

Copied

Did u solve the problem?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 15, 2010 0