Always a particularly uncomfortable stone in actionscript’s boot, dynamically loading fonts at runtime has always been difficult. Many of my projects in the past have used library fonts as runtime shared libraries from the standpoint that once downloaded, it’ll be available across projects. It was never the cleanest of solutions and besides, the entire font had to be loaded – no choosing which character sets to embed, it was all or nothing.

This didn’t solve the problem of catering to markets that required special fonts that supported either greek or east asian character sets. I once got round the problem with one of our jaguar sites by an elaborate level loading process that I forget now and probably couldn’t explain any more :).

Enter AS3 and the magical getDefinitionByName() method. With it, you can retrieve and instantiate classes as long as you know their fully qualified class names. Yes – even from loaded SWFs.

From there, all you need do is embed a font (explicitly specifying the unicode ranges of character outlines that you want) into a class inside a SWF, load that swf at run-time and extract the font from it. Add it to your main SWF’s fontlist and it’s instantly available to use!

Granted, I may have simplified my description a tad, but those are the essentials. In my latest AS3 project, my initial setup loads a config XML file, a localised copy file, a CSS styles file and a handfull of fonts needed to render the text within the app. Should I need to configure the application for the Japanese market for example, I can completely reconfigure the app and it’s fonts to support the Japanese characters without republishing.

Now that’s how it’s supposed to be!!

Check these articles out for a more detailed explanation:

http://www.betriebsraum.de/…runtime-font-loading-with-as3/
http://www.mikechambers.com/…class-reference-by-class-name/
http://www.scottgmorgan.com/…runtime-font-embedding-in-as3/