Where to find the right fontName

 

To preface, I embed fonts using the Embed metatag and fontName parameter with an SWF as the source. If you’re unfamiliar with this method, it looks like this:

1
2
[Embed(source="assets/fonts.swf", fontName="Helvetica")]
protected static const HELVETICA:String;

This past week, I came across the same issue twice. Up until now, I only worked with fonts that used the fontName as it appears in Flash’s properties panel. Sure, this works for fonts with simple names, but when you start getting fancy, things get messy. I needed to embed Alternate Gothic No. 2 and Flash labeled it as “AlternateGothic” with “No2″ as the style. I set the fontName as “AlternateGothic No2″ and was presented with this familiar gem:

fontname_error

I get shivers each time I see it. After a few minutes of failed guess and check, I set out for a solution. I opened FontExplorer X and discovered that the font is labeled as “AlternateGothic-No2″.I gave it a shot and boom went the dynamite. From then on, I thought that would be the correct fontName—the font’s label in Font Explorer X.

fontname_fontexplorer

I was wrong. This week, I needed to embed Helvetica Neue Roman, which is labeled as “12 pt Helvetica* 55 Roman 05472″ in FontExplorer X—freaky, eh? I tried it out and the error returned. At first, I was bummed because I thought I had a foolproof solution. I was close, but no cigar. I opened Font Book to get a second opinion. Apparently, the font’s true name is “12 pt Helvetica* 55 Roman 05472″, which means FontExplorer X removes redundant whitespace, found in our example between “Roman” and “05472.” I tried it out and, sweet sassy molassy, it worked.

fontname_fontbook

From now on, I’ll consult Font Book when embedding a new font.

2 replies

  1. You can just ask Flash what it thinks the font name is and get it right every time. Create a font symbol in the library, then in actionscript:
    var myFont = new myEmbeddedFont();
    trace (myFont.fontName);

    I’ve had to do this a lot with Asian fonts as the Flash IDE oh-so-helpfully lists the font name in kanji. :/

  2. @Dan — Sweet! That simplifies the process a bit. :)

Reply