How to: embed dfont fonts on OS X in Adobe Flex and AIR apps

If you're on a Mac, you cannot embed fonts in Flex or AIR apps directly from the dfont files that come with the system. However, you can do this:

  1. Install fondu (sudo port install fondu or get the OS X package)
  2. Copy the fonts you want to convert from /System/Fonts to, say, ~/mydfonts
  3. Switch the output folder (e.g., cd ~/mynewfonts)
  4. In Terminal, invoke fondu (fondu ~/mydfonts/*.dfont)
  5. In your Flex Builder project properties, add the following compiler tag: -managers flash.fonts.AFEFontManager (or else you'll get an exception during transcoding: Unexpected exception encountered while reading font file error)
  6. Finally, embed the font as you would normally via CSS. e.g.,

    @font-face {
      src: url("fonts/Geneva.ttf") ;
      font-family: "GenevaAIR";
      advanced-anti-aliasing: true;
    }

Comments