Salomonsson.se
Jul 31 2010

Embedded fonts disappear when updating to Flex SDK 4.1

I recently updated my flex SDK to 4.1, (from 3.x) just to find that all my embedded fonts were missing.

This was the scenario:

  • Embedding fonts using the [Embed] meta tag
  • Applying font using TextFormat (don’t know what happens if you use CSS, my guess is that it won’t work either)

Quick fix: note the “embedAsCFF”

[Embed(source="font.ttf", fontFamily="x", mimeType="application/x-font", embedAsCFF="false")]
public var FontClass:Class;

What is this?

I used the Font.enumerateFonts() to get an array of my embedded fonts (my font was there, but still not visible in my textfield). Check the fontType-property. Here I found that it was “embeddedCFF” instead of “embedded”. What is the difference?

“embeddedCFF” is a bit more lightweight, but can only be used with the new text engine (flash.text.engine.*). “embedded” is an embedded font, but can only be used with the older flash.text.TextField.

Since the SDK 4.1 it seems like fonts are embedded as CFF by default, which breaks all the fonts in TextFields if you have coded with an earlier SDK before.

Docs about this: Livedocs about FontType.

Hope this helps. Good luck.