8 Replies Latest reply on Jun 3, 2011 4:51 AM by Subodh K Sharma

    Unable to load embedded fonts in TLF using SWFContext

    Subodh K Sharma


          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.
              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));   
             3). And, when I load the slide1.swf in FB4 MX Flex Poject, it shows the embedded text.  // Output is fine