December 12, 2003

Font formats and getFontList ()

One of my recent projects included the development of a small font browser/viewer application, which is launched from an active desktop containing various little tools to help in media design (font browser, color scheme planner, links to programming/scripting resources and various syntax lookup.).

The font viewer generates a list of the available fonts on a users system using the getFontList() method of the TextField class. Functionality includes the option to select a font name and have it applied to default text, input custom text, apply formatting (bold, italic) and set point size. I knew when going into this that not all fonts on a system would be readable. For example, Adobe PostScript/Type1 fonts, however a problem I ran into was a large number of Japanese fonts on my system would not correctly display, although they did appear in the generated font list. My first thought was that I had made a scripting error or not included the proper formatting. After looking through the code and browsing some online resource I was at a loss. While one font would display perfectly, the next in the list (from the same font house and font family), would not. Rather clueless at this point, I turned to Graeme to pick his wealth o' Flash knowledge, but still could not figure out the problem (Thanks for the help anyway Graeme!)

*Note: Setting the System.useCodepage property to true made no difference.

After all this, I assumed the problem must have its origin outside the Flash Player. Read on to see what I found.

As I mentioned previously, I was aware some fonts would or would not display in the font list, however I DIDN'T know that some fonts would be listed, but not be fully supported. I figured this out after I opened up my fonts folder (working in Win2k) and looked for the specific fonts not displaying...and was hit with the fact that they were a different flavor or TrueType. Rather than your standard True Type Font (TTF), these were True Type Collection (TTC) fonts. It turns out that none of these (Japanese or otherwise) would display correctly when applied in the font browser.

After figuring that out, I went ahead to experiment with another format as well, OpenType. With OpenType, it is really impossible to tell if they will display or not. Simply put, some will and some won't. Because OT can have different extensions and allow for greater options for the type designer (encoding, type of curves, etc), you just have to test to see what will work and what will not.

Below are examples of the icons (win2k) for each font format I mentioned above. Maybe this information was already common knowledge, but if not, I hope someone finds it useful and they do not have to waste as much time as I did finding the cause of the problem.

fontformats.gif

Finally, it should be noted that while they did not display in the font browser, all three (True Type, True Type Collection and OpenType) displayed perfectly within the Flash authoring environment.

Posted by Kris at December 12, 2003 07:33 PM
 



Comments