Skip to main content
Participant
August 21, 2009
Question

Problem with non-embedded chinese text

  • August 21, 2009
  • 1 reply
  • 1143 views

I'm in the process of making a multi-language site and I've been looking into using the new text layout engine.

One of the requirements is that when the site displays chinese characters it uses the users system fonts and not embedded fonts. I've been unable to get this to work. Here is my test code. It creates a textfield using the textlayout and one using just textfield. The textfield one is showing correctly but the textlayout one does not.

I'm just modifying one of the adobe examples - my code:

package
{
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.engine.FontLookup;
    import flash.text.engine.TabAlignment;
   
    import flashx.textLayout.container.ContainerController;
    import flashx.textLayout.elements.ParagraphElement;
    import flashx.textLayout.elements.SpanElement;
    import flashx.textLayout.elements.TextFlow;
    import flashx.textLayout.formats.BlockProgression;
    import flashx.textLayout.formats.TabStopFormat;
    import flashx.textLayout.formats.TextLayoutFormat;
   
    public class TextLayoutFormatExample extends Sprite
    {
        public function TextLayoutFormatExample()
        {
            var textFlow:TextFlow = new TextFlow();
            var format:TextLayoutFormat = new TextLayoutFormat();
            format.fontSize = 24;
             format.blockProgression = BlockProgression.RL;
            format.fontLookup = FontLookup.DEVICE;
             textFlow.hostFormat = format;
            var p:ParagraphElement = new ParagraphElement();
            var span:SpanElement = new SpanElement();
            span.text = "华语/華語";
            p.addChildAt(0, span);
            textFlow.addChildAt(0, p);
            var sp:Sprite = new Sprite();
            addChild(sp);
            textFlow.flowComposer.addController(new ContainerController(sp,150,200));
            textFlow.flowComposer.updateAllControllers();
           
            var tf:TextField = new TextField();
            tf.text =  "华语/華語";
            tf.y = 50;
            addChild(tf);
        }
    }
}

I've tested both compiling the swf and simply viewing it on multiple machines and I get the same result. I have also tried arabic text, which shows up correctly.

I'm using Flex_4.0_b1_061009 sdk

Is there something obvious that I'm doing wrong? I tried using a more recent nightly build but it created compile errors all over my code so I switched back.

This topic has been closed for replies.

1 reply

Adobe Employee
August 27, 2009

On your SpanElement try setting locale="zh-CN" or locale="zh-TW".  The font fallback depends on locale.  Note you can set this property on any element and it will inherit to the spans.

Hope that helps,

Richard

JabbyPandaUA
Inspiring
January 20, 2010

  For the further reference of those who are in need, there was a bug in Flash player 10 with displaying non-embedded East Asian characters in TLF.

  This functionality is now partly working in Flash Player 10.1 Beta 2 release, some Chinese characters are rendered as expected, some are not.

  I've created a new topic here http://forums.adobe.com/thread/560324?tstart=0 to discuss it further.