Skip to main content
Participant
August 17, 2011
Question

Sinhala support - Sri Lanka

  • August 17, 2011
  • 1 reply
  • 3056 views

Hi,

I am working on a project at the moment which has the requirement to be localised into Sinhala.

We are working with AS3, CS5 and the TLF, the text is being loaded in XML format.  We are using the font Iskoola Pota.

I have a sample piece of text in xml, I load it in and set the text property of a Textfield instance to the loaded text. The Zero-Width-Joiners (ZWJ) are NOT removed and the glyphs combine correctly (as per the XML), however the line breaks (Text Field wraps the text) in the middle of a word where ZWJ/ZWNJ are present.  The wrapping is what I expect to see as I am purley setting the text property of a clasic text field.

When I use TLF to create TextLine instances and add them to my container, the text breaks correctly - i.e. not in the middle of the word - however the ZWJs are removed causing the letters to be displayed individually (not joined).

This is the AS I am using for reference:

// create a line starting at the previous line (null, as non existant) and breaking at the width

                    var textLine:TextLine = textBlock.createTextLine(null, lineWidth);               

                    while (textLine)

                    {

                              // position the x

                              if (align == TextFormatAlign.CENTER) {

                                        // place this x at x location of the orig textfield + half its width minus half the textWidth of the new line

                                        textLine.x = (xPos + (lineWidth / 2)) - (textLine.textWidth / 2);

                              } else if (align == TextFormatAlign.LEFT) {

                                        // place this x at x location of the orig textfield

                                        textLine.x = xPos;

                              } else {

                                        // place this x at x location of the orig textfield + its width minus the textWidth of the new line

                                        textLine.x = (xPos + lineWidth) - textLine.textWidth;

                              }

                         

                              // add the height of the text

                              yPos += textLine.height;

                         

                              // if not the first line, add some space down

                              if (textLine.previousLine != null) {

                                        yPos += iVerticalLineSpacer;

                              } else {

                                        //add 12%

                                        // TODO - need to come up with a better solution here

                                        yPos += textLine.height * 0.12;

                              }

                         

                              // position the y

                              textLine.y = yPos;

                              // add to sprite

                              container.addChild(textLine);

                              // create a line starting at the previous line (textLine) and breaking at the width

                              textLine = textBlock.createTextLine(textLine, lineWidth);                         

                    }

Does anyone have any insight into how to go about solving this issue?

Thanks for your time,

Dave

This topic has been closed for replies.

1 reply

Participant
August 18, 2011

Hi daithi,

I can not quite understand your issue, could you please show you complement code, so I can see the effect of your issue, thanks. By the way, you use the FTE actually, not TLF.

I am not sure is this your case bellow?

package{

   

   

    import flash.display.Sprite;

    import flash.text.TextFormatAlign;

    import flash.text.engine.ElementFormat;

    import flash.text.engine.FontDescription;

    import flash.text.engine.FontLookup;

    import flash.text.engine.TextBlock;

    import flash.text.engine.TextElement;

    import flash.text.engine.TextLine;

    public class Forum extends Sprite


        {

        [Embed(mimeType="application/x-font", exportSymbol="iskpota", embedAsCFF="true", source="iskpota.ttf", fontName="iskpota")]
        private const iskpota:Class;
       
        public function Forum()
            {
                var xPos:int = 0;
                var yPos:int;
                var align:String;
                var textBlock:TextBlock = new TextBlock();
                var lineWidth:int = 200;
           
                textBlock.content = new TextElement(
                    String.fromCharCode(
                        0x5185, 0x200D, 0x95A3, 0x5E9C, 0x304C, 0x300C, 0x653F, 0x5E9C, 0x30A4,
                        0x30F3, 0x30BF, 0x30FC, 0x30CD, 0x30C3, 0x30C8, 0x30C6, 0x30EC,
                        0x30D3, 0x300D, 0x306E, 0x52D5, 0x753B, 0x914D, 0x4FE1, 0x5411,
                        0x3051, 0x306B, 0x30A2, 0x30C9, 0x30D3, 0x30B7, 0x30B9, 0x30C6,
                        0x30E0, 0x30BA, 0x793E, 0x306E
                    ))
                var elementFormat:ElementFormat = new ElementFormat();
               
                var font:FontDescription = new FontDescription();
                font.fontLookup = FontLookup.EMBEDDED_CFF;
                font.fontName = "Iskpota";
                elementFormat.fontDescription = font;
                textBlock.content.elementFormat = elementFormat;
                // create a line starting at the previous line (null, as non existant) and breaking at the width
                var textLine:TextLine = textBlock.createTextLine(null, lineWidth);
                while (textLine)       
                 {           
                       // position the x
                       if (align == TextFormatAlign.CENTER)
                       {
                          // place this x at x location of the orig textfield + half its width minus half the textWidth of the new line
                            textLine.x = (xPos + (lineWidth / 2)) - (textLine.textWidth / 2);
                       } else if (align == TextFormatAlign.LEFT)
                       {
                         // place this x at x location of the orig textfield                           
                              textLine.x = xPos;
                           
                       } else
                       {
                               
                     // place this x at x location of the orig textfield + its width minus the textWidth of the new line
                            textLine.x = (xPos + lineWidth) - textLine.textWidth;
                       }
                   
                      // add the height of the text
                   
                       yPos += textLine.height;
                     // if not the first line, add some space down
                   
                        if (textLine.previousLine != null)
                       {
                       
//                        yPos += iVerticalLineSpacer;
                        yPos += textLine.height * 0.12;
                       
                       } else
                       {
                           
                       //add 12%
                     // TODO - need to come up with a better solution here
                              yPos += textLine.height * 0.12;
                           
                        }
                   
                    // position the y
                         textLine.y = yPos;
                     // add to sprite
                        this.addChild(textLine);
                     // create a line starting at the previous line (textLine) and breaking at the width
                         textLine = textBlock.createTextLine(textLine, lineWidth); 
                    }
            }
       
        }
    }

daithi_irAuthor
Participant
August 18, 2011

In short the issue I have is:

If i set the text property of a classic textfield directly I can get the following charachter to show up: විද්‍යාව but the lines break incorrectly.

If I use FTE (sorry for the mistake) this charachter does not show up correctly - it breaks like so:

but the lines break correctly.

There is no other code that I have.

I simply have a textfiled on the stage and either use .text to set the text in the first instance and the code in the first post to use FTE to create the textlines.

Here is a quick sample of what I am refering to.  Publish the following and look at the first word in both.  The second block of text displays this word correctly, but wraps the text incorrectly whereas the first block of text renders the first word incorrectly yet wraps the text correctly.

package{

    import flash.display.Sprite;

    import flash.display.MovieClip;

    import flash.text.TextFormatAlign;

    import flash.text.TextField;

    import flash.text.engine.ElementFormat;

    import flash.text.engine.FontDescription;

    import flash.text.engine.FontLookup;

    import flash.text.engine.TextBlock;

    import flash.text.engine.TextElement;

    import flash.text.engine.TextLine;

    public class main extends MovieClip

        {

        [Embed(mimeType="application/x-font", exportSymbol="iskpota", embedAsCFF="true", source="Iskoola Pota.ttf", fontName="iskpota")]

        private const iskpota:Class;

        public function main()

            {

                var xPos:int = 0;

                var yPos:int;

                var align:String;

                var textBlock:TextBlock = new TextBlock();

                var lineWidth:int = 400;

                var sText:String = "විද්‍යාව හා ඒ ආශ්‍රිත ක්‍ෂේත්‍රයයන් පිළිඹඳ විඥානය ක්‍රමයෙන් පුළුල් වීම අනිවාර්‍යය සංසිද්ධියකි. මෙය ක්‍ෂණික ක්‍රියාවලියක් නොවූවත් අඛණ්ඩ ක්‍රියාවලියකි. චන්‍ද්‍රිකා තාක්‍ෂණයෙන් විශ්ව තරණයට පිවිසීම මෙහි එක් උදාහරණයක් ලෙස දැක්විය හැකිය."

                textBlock.content = new TextElement(sText);

                var elementFormat:ElementFormat = new ElementFormat();

                var font:FontDescription = new FontDescription();

                font.fontLookup = FontLookup.EMBEDDED_CFF;

                font.fontName = "Iskpota";

                elementFormat.fontDescription = font;

                textBlock.content.elementFormat = elementFormat;

                // create a line starting at the previous line (null, as non existant) and breaking at the width

                var textLine:TextLine = textBlock.createTextLine(null, lineWidth);

                while (textLine)       

                 {           

                     // place this x at x location of the orig textfield + its width minus the textWidth of the new line

                         textLine.x = xPos;

                      // add the height of the text

                       yPos += textLine.height;

                     // if not the first line, add some space down

                        if (textLine.previousLine != null)

                       {

//                        yPos += iVerticalLineSpacer;

                        yPos += textLine.height * 0.12;

                       } else

                       {

                       //add 12%

                     // TODO - need to come up with a better solution here

                              yPos += textLine.height * 0.12;

                        }

                    // position the y

                         textLine.y = yPos;

                     // add to sprite

                        this.addChild(textLine);

                     // create a line starting at the previous line (textLine) and breaking at the width

                         textLine = textBlock.createTextLine(textLine, lineWidth); 

                    }

     var tf:TextField = new TextField();   

     this.addChild(tf); 

     tf.text = sText; 

     tf.width = lineWidth; 

     tf.multiline = true;

     tf.wordWrap = true;

     tf.y = 100;

     tf.autoSize = "left";

            }

            

        }

    }

Any other assistance would be a great help,

Thanks,

Dave

Message was edited by: daithi_ir incorrect screen shot

Adobe Employee
August 22, 2011

From what you have described, neither FTE nor TextField can show Sinhala correctly.

FTE is Flash Text Engine in player runtime, which is a new text engine. TextField is also in player runtime, but it is not based on FTE.

While, TLF is not in player runtime, which is based on FTE. We cannot help you here. You may want to post all your findings onto player sub-forum http://forums.adobe.com/community/webplayers/flash_player.