Embedding fonts in Flash CS3/AS3

import flash.display.Sprite;
import flash.text.TextField;
import flash.text.Font;
import flash.utils.getDefinitionByName;

    public class SimpleTextPaneTestDrive01 extends Sprite
private static var embeddedFont:Font = null;

public function SimpleTextPaneTestDrive01()
var embeddedFontClass:Class = getDefinitionByName(“Font1”) as Class;
var embeddedFontsArray:Array = Font.enumerateFonts(false);
embeddedFont = embeddedFontsArray[0];
var fmt:TextFormat = new TextFormat();
//fmt.bold = true;
fmt.color =0xffffff;
fmt.size = 16;//Old day fashion: If you embed it in a textfield on stage
//fmt.font = “Helvetica”;
fmt.font = embeddedFont.fontName;

            var tf:TextField = new TextField();
tf.text = “hello world!”;





Loading fonts at runtime
Using hasGlyphs() with embedded fonts


12 Responses to “Embedding fonts in Flash CS3/AS3”

  1. Embedding fonts Class in Flash CS3/AS3 « Flash Enabled - Get Ready With Flash… Says:

    […] July 30th, 2007 · No Comments Here it is a embedding font class by Maohao. […]

  2. jpz presence » Embedding fonts in Flash CS3/AS3 Says:

    […] Embedding fonts in Flash CS3/AS3 […]

  3. Ain Tohvri Says:

    Unfortunately it still doesn’t work with unicode text

  4. Gugusse Says:

    Excuse me, but I think you forgot to use
    tf.embedFont = true;

  5. Ricardo Says:

    It didnt work 😦

  6. Ricardo Says:

    Man, embedding fonts via AS3 is too dificult … I´ve been trying for months with thousands of examples … I´m using Vista … help please

  7. Dorian Says:


    Take a read of this buddy.

  8. johan Says:

    Yay! Thanks.

  9. tekkie Says:

    Dorian: even so, Flash CS3 IDE fails embedding unicode fonts. Only Basic Latin chars make it through the compilation. Added the odd behaviour of renaming the font instances, it’s surely a bug.

  10. som Says:

    Follow the following steps first and then try .. it works:
    To embed a font symbol:

    1. Select Window > Library to open the current FLA file’s library.

    Open the library that you want to add the font symbol to.
    2. Select New Font from the library’s pop-up menu (upper-right corner of the Library panel).
    3. Type a name for the font symbol in the Name text box of the Font Symbol Properties dialog box.
    4. Select a font from the Font menu or type the name as “Font1” of a font in the Font text box.
    5. Select Bold, Italic, or Alias text if you want to apply a style to the font.
    6. Enter the font size to embed, and then click OK to apply the changes and return to your document.

    Your font now appears in the current document’s library.


  11. Alex Says:

    Many thanks! I’ve been searching for info on how to embed a font in an external swf then load it at runtime for ages. With a slight variation of this method – embedding the font in an external file, loading then registering the font I’ve finally succeeded.


  12. Embedding fonts Class in Flash CS3/AS3 | Biitlog Says:

    […] Here it is a embedding font class by Maohao. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: