Skip to main content
Known Participant
January 14, 2011
Question

Missing characters

  • January 14, 2011
  • 1 reply
  • 2942 views

Hi,

I got a problem with missing characters and the font Zapfino. If I use the font with a certain font size and capture the bitmapData of the text field the "f" character disappears. I'm working with the current Hero built, but it happened with earlier versions, too. It only happens if the font size is between 44 and 52. Here is the code of an test application:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        backgroundColor="#000000"
        creationComplete="creationCompleteHandler(event)">
<fx:Style>
  @namespace s "library://ns.adobe.com/flex/spark";
  @namespace mx "library://ns.adobe.com/flex/mx";
 
  @font-face {
   src: url("Zapfino.ttf");
   fontFamily: "ZapfinoEmbedded";
   embedAsCFF: true;
  }
 
  @font-face {
   src: url("Zapfino.ttf");
   fontFamily: "ZapfinoEmbedded";
   fontWeight: bold;
   embedAsCFF: true;
  }
 
  @font-face {
   src: url("Zapfino.ttf");
   fontFamily: "ZapfinoEmbedded";
   fontStyle: italic;
   embedAsCFF: true;
  }
 
  @font-face {
   src: url("Zapfino.ttf");
   fontFamily: "ZapfinoEmbedded";
   fontStyle: italic;
   fontWeight: bold;
   embedAsCFF: true;
  }
</fx:Style>
<fx:Script>
  <![CDATA[
   import flashx.textLayout.conversion.TextConverter;
   import flashx.textLayout.elements.TextFlow;
   import mx.events.FlexEvent;
   import mx.graphics.ImageSnapshot;

   private function creationCompleteHandler(event:FlexEvent):void {
    var textFlowString:String = '<TextFlow whiteSpaceCollapse="preserve" version="2.0.0" xmlns="http://ns.adobe.com/textLayout/2008"><p clearFloats="none" direction="ltr" justificationRule="auto" justificationStyle="auto" leadingModel="auto" paragraphEndIndent="0" paragraphSpaceAfter="0" paragraphSpaceBefore="0" paragraphStartIndent="0" textAlign="left" textAlignLast="start" textIndent="0" textJustify="interWord" wordSpacing="100%,50%,150%"><span alignmentBaseline="useDominantBaseline" backgroundAlpha="1" backgroundColor="transparent" baselineShift="0" breakOpportunity="auto" cffHinting="horizontalStem" color="#ffffff" digitCase="default" digitWidth="default" dominantBaseline="auto" fontFamily="ZapfinoEmbedded" fontLookup="embeddedCFF" fontSize="48" fontStyle="normal" fontWeight="normal" kerning="auto" ligatureLevel="common" lineHeight="120%" lineThrough="false" locale="en" renderingMode="cff" textAlpha="1" textDecoration="none" textRotation="auto" trackingLeft="0" trackingRight="0" typographicCase="default">of af ff10</span></p></TextFlow>';
    var textFlow:TextFlow = TextConverter.importToFlow(textFlowString, TextConverter.TEXT_LAYOUT_FORMAT);
    text.textFlow = textFlow;
   }

   private function snapshotButton_clickHandler(event:MouseEvent):void {
    var matrix:Matrix = new Matrix(4.921568627450981, 0, 0, 4.923076923076923);
    var bitmapData:BitmapData = ImageSnapshot.captureBitmapData(text, matrix);

    image.source = bitmapData;
   }
  ]]>
</fx:Script>
<s:layout>
  <s:VerticalLayout/>
</s:layout>
<s:RichEditableText id="text"/>

<s:Button id="snapshotButton"
     label="Make snapshot"
     click="snapshotButton_clickHandler(event)"/>
<s:BitmapImage id="image"/>
</s:WindowedApplication>

This topic has been closed for replies.

1 reply

Adobe Employee
January 17, 2011

I've reproduced this here, and it looks to me like a Flash bug. I've written it up. I think it may have to do also with the matrix you're using -- i.e., the scaled font size together with the bitmap size. I haven't tried it, but you may be able to workaround the bug by creating a BitmapData directly (instead of using ImageSnapshot)  that is slightly bigger.

Thanks very much for reporting this,

- robin

Known Participant
January 17, 2011

Thank you for replying and for analysing the problem. If the bug is saved in the official bug tracker may I get the link?

I tried different things to fix it, but the problem is: the user is able to select the font size and it's quite a large range of font sizes that have this bug. I might have to remove the font and replace it with a similar one (but this is quite difficult ).

Inspiring
August 11, 2011

In a new case a customer found a new issue similar to this one, but now whole words disappear. I think this is a major problem in the font rendering and because of that I rewrote my test application to reproduce the new issue (the text is some gibberish to visualize the problem):

In the gray area you can see the captured text from the text field above.

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                            xmlns:s="library://ns.adobe.com/flex/spark"
                            xmlns:mx="library://ns.adobe.com/flex/mx"
                            backgroundColor="#ffffff"
                            creationComplete="creationCompleteHandler(event)"
                            width="1200"
                            height="500">
     <fx:Style>
          @font-face {
               src: url(Zapfino.ttf);
               fontFamily: ZapfinoEmbedded;
               embedAsCFF: true;
          }
          
          @font-face {
               src: url(Zapfino.ttf);
               fontFamily: ZapfinoEmbedded;
               fontWeight: bold;
               embedAsCFF: true;
          }
          
          @font-face {
               src: url(Zapfino.ttf);
               fontFamily: ZapfinoEmbedded;
               fontStyle: italic;
               embedAsCFF: true;
          }
          
          @font-face {
               src: url(Zapfino.ttf);
               fontFamily: ZapfinoEmbedded;
               fontStyle: italic;
               fontWeight: bold;
               embedAsCFF: true;
          }
     </fx:Style>
     <fx:Script>
          <![CDATA[
               import flashx.textLayout.conversion.TextConverter;
               import flashx.textLayout.elements.TextFlow;
               import mx.events.FlexEvent;
               import mx.graphics.ImageSnapshot;

               private function creationCompleteHandler(event:FlexEvent):void {
                    var textFlowString:String = '<TextFlow whiteSpaceCollapse="preserve" version="2.0.0" xmlns="http://ns.adobe.com/textLayout/2008"><p clearFloats="none" direction="ltr" justificationRule="auto" justificationStyle="auto" leadingModel="auto" paragraphEndIndent="0" paragraphSpaceAfter="0" paragraphSpaceBefore="0" paragraphStartIndent="0" textAlign="left" textAlignLast="start" textIndent="0" textJustify="interWord" wordSpacing="100%,50%,150%"><span alignmentBaseline="useDominantBaseline" backgroundAlpha="1" backgroundColor="transparent" baselineShift="0" breakOpportunity="auto" cffHinting="horizontalStem" color="#000000" digitCase="default" digitWidth="default" dominantBaseline="auto" fontFamily="ZapfinoEmbedded" fontLookup="embeddedCFF" fontSize="29.333333333333332" fontStyle="normal" fontWeight="normal" kerning="auto" ligatureLevel="common" lineHeight="120%" lineThrough="false" locale="en" renderingMode="cff" textAlpha="1" textDecoration="none" textRotation="auto" trackingLeft="0" trackingRight="0" typographicCase="default">Jodin kehto min Kanominus Halm, </span><span alignmentBaseline="useDominantBaseline" backgroundAlpha="1" backgroundColor="transparent" baselineShift="0" breakOpportunity="auto" cffHinting="horizontalStem" color="#000000" digitCase="default" digitWidth="default" dominantBaseline="auto" fontFamily="ZapfinoEmbedded" fontLookup="embeddedCFF" fontSize="53.33333333333333" fontStyle="normal" fontWeight="normal" kerning="auto" ligatureLevel="common" lineHeight="120%" lineThrough="false" locale="en" renderingMode="cff" textAlpha="1" textDecoration="none" textRotation="auto" trackingLeft="0" trackingRight="0" typographicCase="default">ginmunzum</span><span alignmentBaseline="useDominantBaseline" backgroundAlpha="1" backgroundColor="transparent" baselineShift="0" breakOpportunity="auto" cffHinting="horizontalStem" color="#000000" digitCase="default" digitWidth="default" dominantBaseline="auto" fontFamily="ZapfinoEmbedded" fontLookup="embeddedCFF" fontSize="29.333333333333332" fontStyle="normal" fontWeight="normal" kerning="auto" ligatureLevel="common" lineHeight="120%" lineThrough="false" locale="en" renderingMode="cff" textAlpha="1" textDecoration="none" textRotation="auto" trackingLeft="0" trackingRight="0" typographicCase="default"> jukan nia tiv </span><span alignmentBaseline="useDominantBaseline" backgroundAlpha="1" backgroundColor="transparent" baselineShift="0" breakOpportunity="auto" cffHinting="horizontalStem" color="#000000" digitCase="default" digitWidth="default" dominantBaseline="auto" fontFamily="ZapfinoEmbedded" fontLookup="embeddedCFF" fontSize="53.33333333333333" fontStyle="normal" fontWeight="normal" kerning="auto" ligatureLevel="common" lineHeight="120%" lineThrough="false" locale="en" renderingMode="cff" textAlpha="1" textDecoration="none" textRotation="auto" trackingLeft="0" trackingRight="0" typographicCase="default">Gibvq</span><span alignmentBaseline="useDominantBaseline" backgroundAlpha="1" backgroundColor="transparent" baselineShift="0" breakOpportunity="auto" cffHinting="horizontalStem" color="#000000" digitCase="default" digitWidth="default" dominantBaseline="auto" fontFamily="ZapfinoEmbedded" fontLookup="embeddedCFF" fontSize="29.333333333333332" fontStyle="normal" fontWeight="normal" kerning="auto" ligatureLevel="common" lineHeight="120%" lineThrough="false" locale="en" renderingMode="cff" textAlpha="1" textDecoration="none" textRotation="auto" trackingLeft="0" trackingRight="0" typographicCase="default">.</span></p></TextFlow>';
                    var textFlow:TextFlow = TextConverter.importToFlow(textFlowString, TextConverter.TEXT_LAYOUT_FORMAT);
                    text.textFlow = textFlow;
               }

               private function snapshotButton_clickHandler(event:MouseEvent):void {
                    var matrix:Matrix = new Matrix(4.921875, 0, 0, 4.921409214092141, 516.796875, 516.7479674796748);
                    var data:BitmapData = new BitmapData(7560, 1816, false, 0xd9d9e0);
                    data.draw(text, matrix);
                    image.source = data;
               }
          ]]>
     </fx:Script>
     <s:layout>
          <s:VerticalLayout/>
     </s:layout>
     <s:RichEditableText id="text"
                              scaleX="0.54"
                              scaleY="0.54"/>
     <s:Button id="snapshotButton"
                 label="Make snapshot"
                 click="snapshotButton_clickHandler(event)"/>
     <s:BitmapImage id="image"
                       scaleX="0.1"
                       scaleY="0.1"
                       smooth="true"/>
</s:WindowedApplication>