This article describes how you can utilize the Adobe Font Development Kit to rename fonts that Flash does not recognizes because of whitespace in the font name.
If you want to embed a font in AS3 you have to use the font name in the [Embed] metadata. Very often the name of the font is not the same like the name the font is represented in programs like Flash. You can find out the real name but just double clicking it. In a windows environment the internal font viewer opens and you can read the internal name at the very top.
The problems start if the name of the font contains whitespaces like this e.g :
“Univers LT 47 CondensedLt”.
Flash seems to have a problem with fontname like this and will throw an error like:
font 'Univers LT 47 CondensedLt' with normal weight and regular style not found
I do not know any other way around that problem but renaming the font internally. You can use commercial products for this but there is a cost free solution by Adobe.
The Font Development Kit provides us with some useful tools around TrueType and OpenType fonts. The tools are command-line tools without any GUI but you will see it’s easy enough! Follow these steps:
- Download the FDK from Adobe (you have to read and agree to the Licence Agreement)
- Unpack/Install the package to the folder of your choice (e.g. c:\AdobeFDK)
- Put the folder into your Windows Invironment Path so the tools are available from anywhere
Setting Up Your Environment For Adoble FDK
1. and 2. are obvious. Here you can find out how to put your FDK folder into the invironment path from windows. Add the following folder to the windows path:
where [yourPath] needs to be substituted by your path on your harddrive (obvious, isn’t it?).
When you are all set open a command line window (Start-Execute: type in:cmd) and change to the directory your wrongly named font lives in. Now it’s time to test if you setup the path correctly. Type : ttx -h and hit enter. The help description of the tool ttx should be shown. If yes, your are ready to go – if not, check the steps above.
Export A XML Dump Of Your Font
Now you can start to export a xml dump of your font to change the internal name. Type: ttx [yourFontName] (e.g: txx ArialRegular.ttf) and hit enter. Your command window should print something like: Dumping ‘ArialRegular.ttf’ to ‘ArialRegular.ttx’. If you look in your directory you will find exactly that file. Open it with your xml editor of choice (not notepad or any other encoding unaware editor) and you see a hugh xml file.
Changing The Internal Name
If you want have a look around in the xml file to get a glimpse of what a font is made of. But at the end you need to find the position where you need to change the name to get it working in Flash. Search for the name your font is named in Photoshop or Flash. Something like: “Arial Regular”. (pay close attention to the space between the words, thats why AS3 cannot use it. Occationally you will find some places where it is already named like “Arial-Regular”, but as long as you can find places where the name has whitespaces in it and you have the feeling (based on the words arround that position) that this section of the xml file deals with the name of your font, change it to another name without spaces (e.g Arial-Regular). Search for ANY occurance. Afterwards save the file.
Saving The XML Back To A Font File
Now you need to bring that change back into your font file. (making a backup copy of your original file is not neccassary since the tool will not overwrite an existing font file but do it if you want). You can build a font with your changed xml settings by typing:
ttx -m ArialRegular.ttx ArialRegular.ttf
The option parameter m tells the tool to merge a given ttx file with a font file. It should say something like: ‘Compiling ‘ArialRegular.ttx’ to ‘ArialRegular.ttf’. Have a look in your folder and you see that there is another *.ttf (or *.otf) file – your newly created Arial-Regular. Doubleclick the font file and you should see the new internal name “Arial-Regular” in your windows font viewer.
Try to embed that font file and everything should work like a charm.