# AS3 Font Embedding

**URL:** <https://forum.kirupa.com/t/as3-font-embedding/324577>\
**Category:** flash\
**Created:** [August 28, 2011, 10:41am UTC](https://forum.kirupa.com/t/as3-font-embedding/324577 "2011-08-28T10:41:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![remote](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@remote](https://forum.kirupa.com/u/remote)\
**Post date:** [August 28, 2011, 10:41am UTC](https://forum.kirupa.com/t/as3-font-embedding/324577/1 "2011-08-28T10:41:53Z")

</div>

EDIT:  
\*\*Problem solved.  
Turns out, when targeting FP10, you have to specify an additional parameter for the [Embed] tag when creating the font SWF:  
embedAsCFF=‘false’.

Otherwise the font cannot be used with Textfield().\*\*

I’ve spent close to four hours trying to get this banal issue resolved.  
I want to use an embedded font in my AS3 project and no matter what technique I try, it does not work.

After having tried exported Font SWF/SWC from Flash CS5 as well as via the FDT Font Library, I have now created the font SWF according to this [article](http://www.scottgmorgan.com/blog/index.php/2007/06/18/runtime-font-embedding-in-as3-there-is-no-need-to-embed-the-entire-fontset-anymore/).

When I load the font and register it, everything seems fine:

[FONT=courier new]constructor:[/FONT]

```auto

var loader:Loader = new Loader(); 
loader.contentLoaderInfo.addEventListener(Event.INIT, init); 
loader.load(new URLRequest("assets/_Rockwell.swf"));

```

[FONT=courier new]init() listener:[/FONT]

```auto

var FontLibrary:Class = event.target.applicationDomain.getDefinition("_Rockwell") as Class;
Font.registerFont(FontLibrary._Rockwell);
showEmbeddedFonts();

```

showEmbeddedFonts() function:

```auto

var fonts:Array = Font.enumerateFonts(); 
fonts.sortOn("fontName", Array.CASEINSENSITIVE); 

for (var i:int = 0; i < fonts.length; i++) 
{
     trace(fonts*.fontName + ", " + fonts*.fontStyle);
}

```

trace output: [FONT=courier new]"\_Rockwell, regular"[/FONT]

However, when I try to use it in a different class of that project (after the font has loaded of course) the text disappears (system fonts do show up).

[FONT=courier new]excerpt of class TextItem():[/FONT]

```auto

// set text styles
var format : TextFormat = new TextFormat();

format.font = "_Rockwell";
format.bold = false;
format.color = _color;
format.size = _textSize;

_textfield.defaultTextFormat = format;
_textfield.embedFonts = true;

```

Any ideas as to what I have missed here? ☹
