• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

TLF and CFF font embedding

New Here ,
Sep 10, 2009 Sep 10, 2009

Copy link to clipboard

Copied

Hello,

I have been trying recently to use the TextLayout framework within Flash CS4 quite successfully (I am really excited about the RTL support). The only major problem I encountered concerns cff font embedding in dynamically loaded SWFs.

For several reasons, I'd like to keep the TLF component and embedded fonts in a SWF module separated from the main application (size, compile time, reusability) and load it dynamically on startup. However, the embedded fonts are unavailable to TLF (even though they are listed by Font.enumerateFonts()). I tried to create the runtime libraries both through Flash CS4 and Gumbo (Flex 4). They are being loaded at the startup, I tried to add them to the stage, instantiate the font classes, Font.registerFont - anything I could think of.

The TLF components loads fine and I have full access to its capabilities, only the fonts are unavailable (the device fonts being used instead).

Everything works as it should when I embed the fonts and TLF component directly into the main SWF. (But the compile time is terribly long and the fonts and the framework cannot be shared; so I'd really like to load them dynamically.)

Is it a known issue? Anyone encountered this?

Thanks in advance.

---

Example of the external font swf (for Gumbo):

package {
    import flash.display.MovieClip;
    import flash.text.Font;

    public class Embed extends MovieClip {
       
        [Embed(source="arialbd.ttf",
                    fontFamily="Arial CFF",
                    mimeType = "application/x-font",
                    fontWeight = "bold",
                    cff = "true")]
        public var Font1:Class;
       
        [Embed(source="AGSCHBQM.TTF",
                    fontFamily="Akzidenz Grotesk BE Bold",
                    mimeType = "application/x-font",
                    fontWeight = "normal",
                    cff = "true")]
        public var Font2:Class;
       
       

        [SWF(width = "1024", height = "768")]
       
       
        public function Embed() {
            Font.registerFont(Font1);
            Font.registerFont(Font2);
        }
    }
}

TOPICS
Text layout framework

Views

6.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 10, 2009 Sep 10, 2009

Copy link to clipboard

Copied

Hi!

... we were folloving this example, and it was working 😃

http://forums.adobe.com/thread/465439

... we build our application in a flex 3.4 project, with the latest textLayout.swc...

one flex4 ActionScript project in eclipse: fonts.swf

package {
    import flash.display.Sprite;
    import flash.text.Font;
    
    public class fonts extends Sprite
    {
        public function fonts()
        {
//            super();
            var length:int = fonts.length;
            for(var i:int; i<length; i++)
            {
                Font.registerFont(this[fonts]);
            }
        }

        [Embed(source="fonts/MinionPro-Regular.otf", fontFamily="MinionPro", cff="true", unicodeRange="U+0020-U+007E,U+00A1-U+00FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183")]
        public const MinionPro:Class;
        [Embed(source="fonts/MinionPro-Bold.otf", fontFamily="MinionPro", fontWeight="bold", cff="true", unicodeRange="U+0020-U+007E,U+00A1-U+00FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183")]
        public const MinionProBold:Class;

        [Embed(source="fonts/MinionPro-It.otf", fontFamily="MinionPro", fontStyle="italic", cff="true", unicodeRange="U+0020-U+007E,U+00A1-U+00FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183")]
        public const MinionProItalic:Class;

        [Embed(source="fonts/MinionPro-BoldIt.otf", fontFamily="MinionPro", fontWeight="bold", fontStyle="italic", cff="true", unicodeRange="U+0020-U+007E,U+00A1-U+00FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183")]
        public const MinionProBoldItalic:Class;

        private static const fonts:Array =
        [
            'MinionPro',
            'MinionProBold',
            'MinionProItalic',
            'MinionProBoldItalic',
        ];
    }

}

- then in the flex 3.4 project you should just load the fonts.swf first....

- and where you create the textFlow you have to set these properties on it:

textFlow.fontLookup = FontLookup.EMBEDDED_CFF;
textFlow.renderingMode = RenderingMode.CFF;

and that is all...

and also you should be able to see all embedded fonts: Font.enumerateFonts(false);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 13, 2009 Sep 13, 2009

Copy link to clipboard

Copied

Thanks, Peter, for your answer.

Basically, that is what I've been doing so far. The problem seems to be limited to the use of dynamically loaded embedded fonts in Flash CS4 projects.

Anyone succeeded in loading external swf with embedded CFF font into a Flash CS4 project and use it within the TextLayout framework?

(In my attempts, the fonts appear in the Font.enumerateFonts() list, but TextLayout fails to find them and uses device fonts instead.)

Jiri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 15, 2009 Sep 15, 2009

Copy link to clipboard

Copied

FIXED: I was trying to reference the fonts by the name assigned in the registerFont call rather than the fontFamily parameter in the embed. my bad.

I'm seeing the same result as Yeri T ( except that I'm using FlashBuilder 4 beta) - fonts are embedded in the external swf, they enumerate correctly after loading them in, but when I set the TextLayoutFormat.fontFamily to the string that matches the class name, the generated textlines are all still in Arial as far as I can tell.

This is what my font class looks like:

package
{
    import flash.display.Sprite;
    import flash.text.Font;
   
    public class MyFonts extends Sprite
    {
       
        [Embed(source="../bin-debug/fonts/AJensonPro-Regular.otf", fontFamily="AdobeJensonPro", cff="true")]
        public const JensonPro : Class;
       
        [Embed(source="../bin-debug/fonts/AJensonPro-Bold.otf", fontFamily="AdobeJensonPro", fontWeight="bold", cff="true")]
        public const JensonProBold : Class;
       
         private static const MyFonts:Array =
        [
            'JensonPro',
            'JensonProBold'
        ];
       
        public function MyFonts()
        {
            super();
            var length:int = MyFonts.length;
            for (var i:int; i < length; i++) {
                Font.registerFont(this[MyFonts]);
            }
        }
    }
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 16, 2009 Sep 16, 2009

Copy link to clipboard

Copied

LATEST

You must not forget to set

_flow.fontLookup = FontLookup.EMBEDDED_CFF;
_flow.renderingMode = RenderingMode.CFF;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines