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

Unable to load embedded fonts in TLF using SWFContext

New Here ,
May 30, 2011 May 30, 2011

Copy link to clipboard

Copied

Hi,


    We are having issues with embedding/renderring fonts in swf.

     Here is the code of the slide1.swf compiled by mxmlc.exe [Adobe Flex  Compiler (mxmlc) Version 4.1.0 build 16076] with compiler parameters --   "-static-link-runtime-shared-libraries".  and using Flash player  version 10.1, 10.2 & 10.3.
   
    package
    {
        import flash.display.Sprite;
        import flashx.textLayout.compose.ISWFContext;
       
        public class Slide1 extends Sprite implements ISWFContext
        {
             [Embed(source="C:/WINDOWS/FONTS/CALIBRI.TTF", fontName="Calibri",  embedAsCFF = "true",  unicodeRange="U+0041,U+0072,U+0069,U+0061,U+006C,U+0020,U+004E,U+006F  ,U+006D", mimeType="application/x-font")]
            public static const calibri:Class;
           
            [Embed("slide1/sldBg1.png", mimeType="image/png")]
            public static const bg:Class;
           
            [Embed("slide1/slide1.xml", mimeType="application/octet-stream")]
            public static const slide:Class;
           
            public function callInContext(fn:Function, thisArg:Object, argsArray:Array, returns:Boolean=true):*
            {
                if (returns)
                return fn.apply(thisArg, argsArray);
                fn.apply(thisArg, argsArray);
            }
        }
    }
   
   
    Using Flex 4.1 SDK:--
   
        1). When I load the slide1.swf in FB4 ActionScript Project it shows the embedded text. // Output is fine


   
        2). When I load the slide1.swf in FB4 MX+Spark Flex Project, it gives an error :
       
             Error TypeError: Error #1034: Type Coercion failed: cannot convert Slide1@f56fce9 to mx.core.IFlexModuleFactory. !

            Below is the code where the exception occurs.
   
            var fontClass:Class = ApplicationDomain.currentDomain.getDefinition("Slide1") as Class;
   
            textFlow.flowComposer.swfContext = new fontClass();   // Exception occurs here

             textFlow.flowComposer.addController(new ContainerController(textContainer, containerWidth, containerHeight));   
            textFlow.flowComposer.updateAllControllers();           
            textFlow.flowComposer.composeToPosition();
   
   
       3). And, when I load the slide1.swf in FB4 MX Flex Poject, it shows the embedded text.  // Output is fine
   

Views

1.5K

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
Adobe Employee ,
Jun 01, 2011 Jun 01, 2011

Copy link to clipboard

Copied

Looks like you'll have to re-build slide1.swf without -static-link-runtime-shared-libraries. MX+Spark project links in RSLs that might not be compatible with the RSLs that have been compiled into your embedded font SWF.

I'm curious, have you thought about using a CSS Module? (Right click a CSS file and choose "Compile to SWF).

-Anirudh

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 ,
Jun 02, 2011 Jun 02, 2011

Copy link to clipboard

Copied

After rebuilding the slide without parameters following warning is shown in the command prompt

Warning: This compilation unit did not have a factoryClass specified in Frame metadata to load the configured runtime shared libraries. To compile without runtime shared libraries either set the -static-link-runtime-shared-libraries option to true or remove the -runtime-shared-libraries option.

We can't use the CSS Module as the slide will not only contain the embedded fonts but also the visuals contained in the slide1.xml which are rendered at runtime when the slide1.swf is played in the container, which is the pure actionscript project.

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
Adobe Employee ,
Jun 02, 2011 Jun 02, 2011

Copy link to clipboard

Copied

Then use a normal module?

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 ,
Jun 02, 2011 Jun 02, 2011

Copy link to clipboard

Copied

We have the following flow for the project using Flex SDK 4.1:--

1). First case which have no problem:--

     UI is in Flash CS4 with document class written in FB4 Action script project. ---- A.swf

     API controller written in FB4 Action script project. ---- B.swf

     Slide renderer written in FB4 Action script project which loads & plays the slide1.swf. --- C.swf

     A.swf communicates with B.swf through Local Connection. B.swf & C.swf have parent-child communication.

2). Second case where the problem is :--

     We want UI as an mxml component to be used in existing Flex Project.

     This component will work as A.swf and have the same communication flow.

     The comminication is fine between all the swf's. Just can't show the embedded fonts using textLayout.

Thanks  

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
Adobe Employee ,
Jun 02, 2011 Jun 02, 2011

Copy link to clipboard

Copied

Fonts have to be embedded with embedAsCFF="true" for TLF. I'm not sure how that translates to Flash CS4.

-Anirudh

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 ,
Jun 02, 2011 Jun 02, 2011

Copy link to clipboard

Copied

Player UI design is in Flash. This has nothing to do with the embedded fonts.

We use this for fonts ----  textFormat.fontLookup = FontLookup.EmbedCFF;

For showing the fonts we use the line of code :--

textFlow.flowComposer.swfContext = new fontClass();

which throws an error

Error TypeError: Error #1034: Type Coercion failed: cannot convert Slide1@f56fce9 to mx.core.IFlexModuleFactory. !

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
Adobe Employee ,
Jun 02, 2011 Jun 02, 2011

Copy link to clipboard

Copied

Right. So the problem is that Slide1's root class is not what Flex expects it to be.

Can you try creating a separate project (MX+Spark) for Slide1 with Flash Builder rather than MXMLC? This is to avoid mismatch between any of the compiler settings that FB sets compared to MXMLC.

If that also yields no results, then you're better off posing this question on the Flex general discussion forum. They'll have a better idea about it.

-Anirudh

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 ,
Jun 03, 2011 Jun 03, 2011

Copy link to clipboard

Copied

LATEST

Okay, If i comment the following line,

textFlow.flowComposer.swfContext = new fontClass(); // Where the exception occurs

there is no error and the slide is displayed with default fonts.

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