Using mxmlc Embed fonts with TextField

NOTE: From Josh’s comment below you can do this in the Embed metadata. See the end of the post for updated code.

With the latest drops of the Flex SDK, 4 and higher, the compiler mxmlc has changed. One of the changes is that it defaults the Spark components to use Text Layout Framework (TLF) for Text fields. TLF is a Flash Player 10.0 plus feature and is built up on the flash.text.engine classes. The mxmlc compiler has allowed you to embed classes through CSS or actionscript with the use of [Embed] metadata.

With the latest mxmlc changes when you use Embed metadata for embeding fonts it embed by default the font as “embeddedCFF” type. This type of embedding of the font is required for the new TLF framework, thus making this type of embed fonts unusable with the plan old TextField and TextFormat. But there is a compiler option to change the way mxmlc embeds the font as a compiler argument. The compiler argument is:

-managers=flash.fonts.AFEFontManager

This is good to know if you are playing with ActionScript 3.0 only projects and want to use the Embed metadata and embedding fonts for use with TextField. Of course you can always just learn TLF and be on your way.

I just upgraded to Flash Builder 4.01 and suddenly I getting a number of warnings of the type “This component requires that the embedded font be declared with embedAsCff=true” yet I am embedding the font with that metadata in my css file. I tried setting the compiler argument as you mentioned but no dice.