• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Embedding Font AS3 w/ Flash Builder 4 OSX

New Here ,
Apr 09, 2010 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.2K

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
community guidelines
New Here ,
Apr 09, 2010 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;

     }

}

Votes

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
community guidelines
New Here ,
Apr 10, 2010 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.

Votes

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
community guidelines
Guest
Apr 12, 2010 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);
        }
    }
}

Votes

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
community guidelines
New Here ,
Aug 13, 2010 Aug 13, 2010

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Participant ,
Nov 15, 2010 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!

Votes

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
community guidelines
Participant ,
Nov 15, 2010 Nov 15, 2010

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines
Participant ,
Nov 15, 2010 Nov 15, 2010

Copy link to clipboard

Copied

Did u solve the problem?

Votes

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
community guidelines