I've blogged before about embedding fonts in Flex applications by first creating an embedded font in a Flash movie. The process is pretty simple and works well with one large caveat, your final SWF is larger based on the file size of any embedded fonts. Why is this bad? If you've embedded four of your favorite fonts and your app is one big Flash movie or Flex application your overall app size is increased to include the font resources.
Wouldn't it be better if you could load the fonts at runtime only when they're needed? Well, you can! Lee Brimelow recorded a fifteen minute tutorial showing you how to use Flash CS4 and Flex SDK metadata to create runtime loaded fonts. He walks through the entire process including selecting a font, writing the ActionScript 3 code to embed a font, restricting the font to certain glyphs, and then embedding the external font movie into a new, separate movie at runtime.
As Lee points out towards the end of the tutorial, using runtime loaded fonts should be considered a best practice if you're using Flash CS4. You can do what we've always been able to do and embed a font directly in the Flash CS4 library, but why tax your entire application this way and why include all the glyphs if you don't need them?
1 related blog entries
- Embedding Fonts in Flex (July 18, 2007)