8 Replies Latest reply on Jun 3, 2011 10:19 AM by Flex harUI

    Unable to load embedded fonts in TLF using SWFContext

    Subodh K Sharma

      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:--
         
              When I load the slide1.swf in FB4 ActionScript Project it shows the embedded text. // Output is fine


         
              But, when I load the slide1.swf in FB4 MX+Spark Flex Project, it gives an error :
             
              Warning: An ActionScript 1.0/2.0 SWF file has loaded an ActionScript 3.0 SWF; code in the ActionScript 3.0 SWF will not run.
              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();
         
         
              And, when I load the slide1.swf in FB4 MX Flex Poject, it shows the embedded text.  // Output is fine
         
         
          Using Flex 4.5 SDK:--
             
              With FB4 MX+ Spark and MX only Flex Project we get following errors
             
              VerifyError: Error #1053: Illegal override of createGeometry in flashx.textLayout.elements.FlowGroupElement.
              VerifyError: Error #1053: Illegal override of canReleaseContentElement in flashx.textLayout.elements.SubParagraphGroupElement.
              VerifyError: Error #1103: Class flashx.textLayout.elements::LinkElement cannot extend final base class.
              VerifyError: Error #1053: Illegal override of display in flashx.textLayout.elements.ContainerFormattedElement.
              VerifyError: Error #1053: Illegal override of canReleaseContentElement in flashx.textLayout.elements.FlowLeafElement.
              VerifyError: Error #1053: Illegal override of addParaTerminator in flashx.textLayout.elements.SpanElement.
              VerifyError: Error #1053: Illegal override of canReleaseContentElement in flashx.textLayout.elements.InlineGraphicElement.
              VerifyError: Error #1053: Illegal override of minPercentValue in flashx.textLayout.property.NumberOrPercentProperty.
              VerifyError: Error #1053: Illegal override of hash in flashx.textLayout.property.EnumStringProperty.
              VerifyError: Error #1053: Illegal override of hash in flashx.textLayout.property.BooleanProperty.
              VerifyError: Error #1053: Illegal override of minValue in flashx.textLayout.property.NumberProperty.
              VerifyError: Error #1014: Class flashx.textLayout.property::NumberProperty could not be found.
              VerifyError: Error #1053: Illegal override of minValue in flashx.textLayout.property.IntProperty.
              VerifyError: Error #1014: Class flashx.textLayout.property::IntProperty could not be found.
              VerifyError: Error #1053: Illegal override of hash in flashx.textLayout.property.UintProperty.
              VerifyError: Error #1014: Class flashx.textLayout.property::UintProperty could not be found.
              VerifyError: Error #1053: Illegal override of hash in flashx.textLayout.property.StringProperty.
              VerifyError: Error #1014: Class flashx.textLayout.property::NumberOrPercentProperty could not be found.
              VerifyError: Error #1053: Illegal override of hash in flashx.textLayout.property.ArrayProperty.
              VerifyError: Error #1103: Class flashx.textLayout.elements::TCYElement cannot extend final base class.
              VerifyError: Error #1053: Illegal override of createTextLine in flashx.textLayout.compose.ComposeState.