Flex/AIR embedded fonts - Exception during Transcoding - Solved

I've come across this error a number of times:

exception during transcoding: Unexpected exception encountered while reading font file '/C:/Documents and Settings/markl/My Documents/Flex Builder 3/DexterNorthCode/src/assets/DejaVuSans-Bold.ttf'

It can be very frustrating as there is not much information to be gleaned from the error messages and the whole font area is very murky and complicated.

There are a number for reasons that this error will occur

  • If you reference the wrong file
  • If you specify the fontStyle or fontWeight wrong
  • or most frustratingly if the font manager can't interpret the font correctly.

After grappling with this problem for I while and after much reading I realised that there are 3 different "font managers" that transcode fonts in AS3. These are:

  • flash.fonts.JREFontManager
  • flash.fonts.AFEFontManager
  • flash.fonts.BatikFontManager

The different font managers have different capabilities and should be automatically selected to choose the best one. However, this is not always the case.

You can force the compiler to use a specific manager by appending the following to the compiler arguments.

Project->Properties->Flex Compiler->Additional compiler arguments:

-managers=flash.fonts.AFEFontManager

This forces the use of the AFEFontManager which seems to have the best support for fonts and is the one being most actively developed.

Comments
I ran into the same problem and the AFEFontManager sovled the problem when publishing. However, I still get the exceptions while working in design mode in the Flex IDE. I have resorted to commenting the embeded fonts in the css while skinning (so that the view renders correctly) and then uncommenting when the project is published. Any Idea how to work around that since it makes it quite difficult to skin/stlye an app when you cannot see the assets as well as the correct fonts in the design view.

Thanks in advance...
SD
# Posted By Shane D | 6/17/08 4:03 PM
This helped me thanks alot!
# Posted By Julien I. | 4/24/09 5:03 AM
This helped me out a lot as well. Just wanted to say thanks as this error was very frustrating. It now makes sense to me why this error appeared out of nowhere! I'd actually been compiling my project fine for a while, and then the error appeared out of the blue with no font file changes! It was a bit infuriating, as you can imagine. Thanks again for passing this tip on and saving a fellow developer's bacon!
# Posted By Robin | 4/27/09 8:45 PM
Hell yeah, just popped by to say thanks. I've had this problem quite a few times. Solved everything!
# Posted By Jordi | 5/27/09 11:02 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.