While I was making a comprehensive test of Croatian letter input field issues in Flash Player 9 (check it out here), I accidentally discovered potential bug, or very strange feature in new Adobe Flash CS3. Embedding fonts in Flex is easy as 1-2-3, doing the same in CS3 IDE is somehow awkward (broken?).
In Flex you would do this (pseudo exemplary code):
[Embed(source="C:\WINDOWS\Fonts\myfont.ttf", fontFamily="myFont")] ... var format:TextFormat= new TextFormat(); format.font= "myFont"; var myTextField= new TextField(); myTextField.embedFonts= true; myTextField.defaultTextFormat = format;
Yeah, that works fine. Ok, how to do this in CS3 IDE? First, you import your font to library - select a font, name it somehow.
Secondly you export it for ActionScript. In theory (as I interpreted Flash help files), you should just use exact font name you entered as format.font property for a TextFormat. In practice - Flash IDE never renamed your font. In fact, if you selected Bitmap Text during the font import, Flash IDE will rename your font suffixing it with '_8pt_st' (in case you selected 8px size). So actually instead using your own name inside TextFormat.font property, you should use the original font name.
Here is a screenshot of a debugger so we all can contemplate about this:
Debugger shows contents of embeddedFonts array:
var embeddedFonts:Array = Font.enumerateFonts(false);
So how to embed fonts trough an IDE? There is a hack. :) Assuming that you have a font in your library which you exported with the class name myEmbeddedFont - instead of using font name in format.font property, you point to the exported library class name (format.font = new myEmbeddedFont().fontName;) like this:
var format:TextFormat= new TextFormat(); format.font = new myEmbeddedFont().fontName; // format.font= "myFont"; var myTextField= new TextField(); myTextField.embedFonts= true; myTextField.defaultTextFormat = format;
The part that troubles me the most, is not the strange renaming inside the IDE, well it does because it's not documented anywhere, but thing that bothers me is the fact that I was unable to display Croatian letters in my old pixel fonts. What am I missing here? Anybody?
Embedded DINMittelschrift HR CZ, Croatian letters show up nicely.
Embedded standard 07_55 hr, which should work, but it doesn't. :(