1 Reply Latest reply on Jun 21, 2011 3:21 AM by invisibleBlade

    Embedding fonts as SWF

    invisibleBlade Level 1

      Hi all,

      I am working on a mobile actionsxcript project and am having trouble embedding some fonts. The fonts are embedded in SWF files as only a small subset is needed and I am trying to embed the SWF files in my AS build and then access the fonts via their linkage names.

      I am not having any luck but am not really sure of the exact approach here so if anyone can shed any light or provide a tutorial/example that would be great as I am about to start banging my head on stuff.

       

      I am embedding the font swf like this:

      [Embed(source="assets/newfonts/FontFile.swf", symbol="fontInstanceName")]

      public var FontBold:Class;

       

      I assume I need to construct an instance and cast it before I can use the font (maybe wrong about this) but am unsure of the details.

       

      Thanks in advance for any help.

        • 1. Re: Embedding fonts as SWF
          invisibleBlade Level 1

          Turns out to be really (embarressingly) simple and I'm not sure how it took me so long to get working.

           

          1. Add a new font to the library in Flash.
          2. Give it a linkage name and set it to export for actionscript.
          3. Publish the SWF
          4. Embed the swf in the actionscript project using [Embed(source="assets/newfonts/FontLib.swf", symbol="TestFontBold")]public var TestFontBold:Class;
          5. Set the 'symbol' parameter in the embed tag to be the flash linkage name of the font.
          6. Create a TextFormat object
          7. Create a Font object - var newFont:Font = new TestFontBold();
          8. Set myTextFormat.font = TestFontBold.fontName;
          9. Apply the TextFormat as usual.

           

          No idea how I had so much trouble with this when it is so obvious and straighforward. Oh well, that's often the case (with me at least)

           

          Cheers