Embedding fonts has been a bane to me for some time, and I finally spent the time to find both the easiest and most comprehensive way to embed needed fonts into a SWF using AS3 only. As always, I try to keep the demos here as lightweight as possible, and I have tried to keep any code snippets I give free from external resources. In this case, there is a small exception, but it is only the exception of using one of the fonts installed on your own computer.
Basically, we need to understand a couple things about the nature of the embedded font in Actionscript. First, it must be assigned to a String in order to store all the character references. Next, you will quickly find that creating and implementing a TextFormat object to attach the font and styles to the different places in which it will be used is ideal. Finally, keep in mind that attaching several fonts to a single application can significantly increase the file size, so try to consolidate and style for variety as much as possible instead of selecting a boat load of different font faces.
Continue reading