0 Replies Latest reply on Feb 3, 2011 4:25 PM by JC169

    Using an Embedded Font in another .swf

    JC169

      I am encountering a situation with font embedding that hopefully someone out there will know the solution to. This is a slightly boiled-down version of the problem but all the pertinent details are included. Without further ado, here's the situation:

       

      TLDR Version:  If I have a font embedded and registered with Font.registerFont(), and I attempt to use that font in a .swf that was compiled from an .fla in Flash CS5 that so much as MENTIONS that font, it fails.

       

      Longer Description:

       

      The Goal: Embed fonts in 1 .swf, use those fonts in many .swfs. Simple.

       

      Fonts.swf
      I have 3 .swf files. The first is called Fonts.swf. This was created in Flash CS5. It contains an embedded font( Franklin Gothic Demi ) with characters a-z, A-Z, numerals, and punctuation, etc. Regular, not bold. The font is exported for actionscript and the class is FranklinGothicDemi.

       

      On the main timeline of Fonts.swf is the code:
      Font.registerFont( FranklinGothicDemi ).

       

      Application.swf
      The second .swf is Application.swf. The following code snippet is from Application.as:

       

      [Embed(source="Fonts.swf")]
      private static var EmbeddedFonts:Class;

       

      initFonts()
      {
      ...
      var embedFont:EmbeddedFonts = new EmbeddedFonts();
      embedFont.addEventListener( Event.COMPLETE, function( e:Event ){ traceEmbeddedFonts(); } );
      ...
      }

       

      When traceEmbeddedFonts is called, it verifies that Franklin Gothic Demi is in fact registered.

       

      UserInterface.swf
      The third .swf file is UserInterface.swf. Fonts are NOT embedded in this file. They are not supposed to be. The project has many .swf files and they should all be using the fonts embedded in Fonts.swf.

       

      On the main timeline of UserInterface, it calls it's own version of traceEmbeddedFonts(), which again confirms that Franklin Gothic Demi is embedded.

       

      Inside UserInterface is a TextField we'll call mMainTextField, with some text, say "Main Menu". The font is "Franklin Gothic Demi", the anti-alias style is 'use device fonts.' I have tried other anti-alias styles as well.

       

      As it turns out, UserInterface.swf is 'embedding' Franklin Gothic Demi, with a character set of a big fat 0 characters. This is taking precedence over the Franklin Gothic Demi font embedded from Fonts.swf. I can side-step this problem by setting mMainTextField to use some other Font while publishing and then using actionscript to change it back to Franklin Gothic Demi when the project is running, but that's not a solution that is friendly to the artists.

       

      In essence, the question is simple: Why is Flash Embedding and Registering fonts with character sets of size 0, despite the fact that nowhere in UserInterface.swf is there a request to embed fonts, and how do I prevent it from doing so?

       

      If anyone who sees this has already encountered and solved this problem and shares the solution with me, you will be my favorite person .

       

      Thanks!

       

      -J