Flex Font Transcoder with FontForge and/or TTX

 Aug, 03 - 2009   1 comment   Uncategorized

I’ve been doing some deep font science as have a bunch of other folks, both with flash and without.

If you want to play along, I highly recommend, O’Reilly’s Fonts and Encodings. It’s the business. Be careful though — it’s a monster. Check with your local laws concerning weapon permits, etc. Also proven effective as a powerful sleep aid!

One of the many useful utilities thoroughly discussed is TTX, an extremely powerful font decompiling / recompiling tool. In short, it allows you to dump TrueType and OpenType to XML, make modifications (or inspections), and roundtrip back into a working font again.

So I’d been playing with this and FontForge, and if you manage to screw up a font so it’s unusable, you’ll get used to Flex giving an error like:

/Users/projects/externalFontLibrary/src/classes/EmbedFontLibrary2.as(14): Error: exception during transcoding: The font file:/Users/projects/externalFontLibrary/mxml/fonts/MyFont.tff is not usable.

[Embed(source="/Users/projects/externalFontLibrary/mxml/fonts/MyFont.ttf", fontFamily="MyFont", mimeType="application/x-font")]

/Users/projects/externalFontLibrary/src/classes/EmbedFontLibrary2.as(14): col: 3: Error: unable to build font 'MyFont'

I’d gotten so used to it, in fact, that I managed to overlook a subtile difference in error message for a font that had actually exported correctly:

TTX will generate unique names for its output files so it doesn’t accidentally overwrite an original. You’ll end up with filenames like: MyModifiedFont#1.ttf

So, let’s try plugging that into our ActionScript class to embed outlines:

[Embed(source="/Users/projects/MyModifiedFont#1.ttf", fontFamily="MyFont", mimeType="application/x-font")]
private var myFont:Class;

To which Flex replies:

/Users/projects/externalFontLibrary/src/classes/EmbedFontLibrary2.as(14): col: 3: Error: transcoding parameter 'symbol' is not supported by 'flex2.compiler.media.FontTranscoder'

[Embed(source="/Users/projects/externalFontLibrary/mxml/fonts/MyModifiedFont#1.ttf", fontFamily="myFont", mimeType="application/x-font")]

/Users/projects/externalFontLibrary/src/classes/EmbedFontLibrary2.as(14): col: 3: Error: Unable to transcode /Users/projects/externalFontLibrary/mxml/fonts/MyModifiedFont.

Maybe you’ve got a sharper eye than I do, or maybe you’re just more clever. In any case, I saw my compile fail and didn’t look closely enough at the details. And the days that became weeks! It never did dawn on me (until today!) that the mysterious “symbol” parameter was the result of the pound symbol (“#”) in the filename! After a rename to remove it, everything works awesomely!

Looking forward to talking about this more. I’m still looking into similar problems that can occur when exporting fonts from FontForge and ttf2eot Online typography is really heating up right now and I’m hoping to assemble some useful developer tools, or at the very least cobble together a workflow I can count on.


Related articles

 Comments 1 comment

  • Kramer auto Pingback[…] Flex Font Transcoder with FontForge and/or TTX I’m still looking into similar problems that can occur when exporting fonts from FontForge and ttf2eot Online typography is really heating up right now and I’m hoping to assemble some useful developer tools, or at the very least cobble … […]


  • Leave a Reply

    Your email address will not be published. Fields with * are mandatory.