6 Replies Latest reply: Aug 22, 2011 9:41 PM by Flex harUI RSS

    Spark DataGrid Embedded Font Quandary

    tcorbet Community Member

      01.  In everything that follows, I am talking about the latest [21328] version of the SDK, not that I believe that my problems have anything to do with that release, just so anyone interested and willing to help will know the version.

       

      02.  My application happens to be rooted in AIR's WindowedApplication, but again, I do not think that has any impact on my problems; I believe the same results would obtain for a Flex Application.

       

      03.  I have a custom renderer for the Spark DataGrid which extends DefaultGridItemRenderer.  It works fine. Its primary job is to change the font characteristics of each row in the list as a visual clue to the user as to the specific nature of the content that is accessible.  Some entries are just in the Regular font, some in Bold, some in Italic, and some in Bold-Italic.

       

      04.  I have, for most of the project, embedded the necessary fonts like this:


          [Embed (source="C:/Windows/Fonts/ArnoPro-Caption.otf", fontName="ArnoPro_BI_4",
              fontStyle="italic",
              fontWeight="bold",
              mimeType="application/x-font",
              embedAsCFF="true",
              unicodeRange="U+0021-U+00ff, U+20ac-U+20ac")]
          private const ArnoPro_BI_4:Class;

       

      As I said, that all works just as advertized.  But, that method of embedding carries the somewhat painful burden of slower compilations, so for the last 24 hours I have unseccessfully been trying to replace that with:

       

      [Embed (source = "../resources/assets/ArnoPro_BI_4.swf", symbol="ArnoPro_BI_4")]
      private const ArnoPro_BI_4:Class;

       

      where the swf file was produced via fontswf, using this incantation:

       

      fontswf -4 -u U+0021-U+00ff,U+20ac-U+20ac -b -i -a ArnoPro_BI_4 -o ArnoPro_BI_4.swf C:/Windows/Fonts/ArnoPro-Caption.otf

       

      06.  By all that is holy, the two different means of embedding the font ought to yield the same result, but they do not.  I have debugging code inserted to print out the list of fonts upon initiation of the application, and they are identical.  Both means of embedding do succeed in getting the embedded fonts into the .swf, but the attempt to use the fonts fails using the second approach.

       

      There is, of course, no change being made to the code in the item renderer which merely uses setStyle() to effect the row-by-row result.  The result in the second case is that the only style of the embedded font that renders is 'regular'.

       

      07.  I have used the 'keep-generated' facility to look at the code being generated by the mxmlc compiler and can see that different code is emitted, but it does not help me find a fix to the problem.  Both forms of the meta-tag do something; both methods of embedding seem to correctly register themselves with the FontManager, but only the method of embedding which actually performs the transcoding during compilation seems to result in a set of registered fronts which can be found and correctly used to render output based on the runtime setting of the font style.

        • 1. Re: Spark DataGrid Embedded Font Quandary
          Flex harUI Adobe Employee

          Not sure how you build the ArnoPro_BI_4 swf, but if it doesn't have the same

          attributes, especially the CFF attribute, then it may not work properly.

          • 2. Re: Spark DataGrid Embedded Font Quandary
            tcorbet Community Member

            Thank for the reply

             

            I hoped that my posting indicated how the fonts in the the .swf file were constructed.  The "-4", argument to the command-line tool, fontswf, as far as I can tell, is the precise analog to the "embedAsCFF" argument in the [Embed] syntax.  That is what makes it so perplexing.  Given all the external documentation that is available for each tool/methodology, I would have thought that the resultant bytecodes, classes, flags, whatever, would have been identical.  The only difference would be the timing of when the transcoding took place.

             

            Since it is clearly more efficient to only transcode whatever set of fonts an application needs once, not once per build/test turn-around, I would really like to make the fontswf workflow work.  For those of us outside the beneficial environment of your licensed tools, the kindly-provided alternative to the facilities built into Flash Professional and/or Flash Builder give us the greatest degree of productivity.

             

            Whoever has access to the source code for Font [I can only see the uninteresting FontAsset in the SDK] can probably determine what difference might result from mxmlc working with this intermediate output, when inline transcoding is 'tagged':

             

            package
            {

            import mx.core.FontAsset;

            [ExcludeClass]
            [Embed(fontName="ArnoPro_IT_4", _resolvedSource="C:/WINDOWS/Fonts/ArnoPro-ItalicCaption.otf", fontStyle="italic", _line="1189", _pathsep="true", embedAsCFF="true", fontWeight="normal", unicodeRange="U+0021-U+00ff, U+20ac-U+20ac", source="C:/Windows/Fonts/ArnoPro-ItalicCaption.otf", _column="2", exportSymbol="AIRZoom_ArnoPro_IT_4", _file="G:/FP/AIRZoom/src/AIRZoom_AS.as", mimeType="application/x-font")]

            public class AIRZoom_ArnoPro_IT_4 extends mx.core.FontAsset
            {
                public function AIRZoom_ArnoPro_IT_4()
                {
                    super();
                }

            }

            }

             

            versus this, when swf extraction is 'tagged':

             

            package
            {

            import mx.core.FontAsset;

            [ExcludeClass]
            [Embed(fontName="ArnoPro_IT_4", _resolvedSource="C:/WINDOWS/Fonts/ArnoPro-ItalicCaption.otf", fontStyle="italic", _line="1191", _pathsep="true", embedAsCFF="true", fontWeight="normal", unicodeRange="U+0021-U+00ff, U+20ac-U+20ac", source="C:/Windows/Fonts/ArnoPro-ItalicCaption.otf", _column="2", exportSymbol="AIRZoom_ArnoPro_IT_4", _file="G:/FP/AIRZoom/src/AIRZoom_AS.as", mimeType="application/x-font")]

            public class AIRZoom_ArnoPro_IT_4 extends mx.core.FontAsset
            {
                public function AIRZoom_ArnoPro_IT_4()
                {
                    super();
                }

            }

            }

             

            The only difference is that value for '_line' which probably only indicates that one of the two processes has a comment or empty line somewhere.

            • 3. Re: Spark DataGrid Embedded Font Quandary
              Flex harUI Adobe Employee

              I'm not sure what you mean by "inline transcoding is 'tagged'".  Font is an

              internal Flash class, there is no AS source for it.

               

              You can try using SWFDump to compare the DefineFont tags in the final SWF.

               

              Are you getting any warnings at runtime?

              • 4. Re: Spark DataGrid Embedded Font Quandary
                tcorbet Community Member

                01.  Sorry for my inventive and not-very-helpful terminology.  I just want some shorthand way to distinquish between the use of an {Embed] meta-data tag for which the source attribute is pointing at some acceptable font resident on my development host as contrasted with the one in which the source attribute is pointing to a .swf file for which transcoding has already been accomplished by means of the fontswf utility.  In the former case, the mxmlc compiler must call whatever routines are necessary to transcode [inline], in the later case, that work has already been accomplished [off-line].

                 

                02.  No compilation errors; no runtime errors, just a silent, perplexing failure for setStyle ("fontStyle', ...) to produce the same result that it does when the embedding was accomplished "inline".

                 

                03. I had not tried swfdump; thanks for that suggestion  I will learn about that tool and see what I might find.

                • 5. Re: Spark DataGrid Embedded Font Quandary
                  tcorbet Community Member

                  I don't know if this is the origin of the problem or not, but it seems like it could be contributing to my problem.

                   

                  Using swfdump to compare the application swf compiled with [Embed source = an external font] to the swf compiled when [Embed source = a swf produced by fontswf] shows differences in the bytecodes that describe a given font that appear to be just noise level.  The key information, found in the <DefineFont4> element's attributes are identical.

                   

                  I then decided to see what the swf coming out of fontswf looked like.  Again, noise level bytecode differences, but complete agreement as to the attributes of the <DefineFont4> element's attributes.

                   

                  Then I looked at the <swf> xml tags.  Since, as I said, I am using the latest Flex SDK, and compiling to take advantage of those features, my application swf files have version set to "11".  The swf produced by fontswf from that same sdk however generates a  version "10" swf format.  So, we can at least say that there is a potential for a different result when the mxmlc compiler performs the compilation AND the transcoding in one fell-swoop, as compared to the condition that it faces when compiling for version "11" but dealing with whatever conversions are required to [Embed] a swf that had been compiled for version "10".

                   

                  I am sure you can tell me whether or not you believe that that difference might account for the silent failure behavior.  Assuming that it might be the cause, the natural question is how do I either get a newer version of fontswf that outputs version "11" swfs, or how do I force the present fontswf to do that?

                  • 6. Re: Spark DataGrid Embedded Font Quandary
                    Flex harUI Adobe Employee

                    You can try debugging into the EmbeddedFontRegistry and see what the

                    difference is there.