public void DoLayout()
        {
            //user can use other native methods
            //to do the layout ***

            //the following code is how-to-layout with
            //our Typography lib
            //

            //then at this step
            //we calculate span size
            //resolve each font style

            _glyphLayout.FontSizeInPoints  = FontSizeInPts; //
            _glyphLayout.EnableComposition = true;
            _glyphLayout.EnableLigature    = true;

            int lineCount = _lines.Count;

            List <GlyphPlan> outputGlyphPlan  = new List <GlyphPlan>();
            GlyphPlanBuffer  glyphPlanBuffer  = new GlyphPlanBuffer(outputGlyphPlan);
            Typeface         selectedTypeface = this.DefaultTypeface;

            for (int i = 0; i < lineCount; ++i)
            {
                EditableTextLine line    = _lines[i];
                List <IRun>      runList = line.UnsageGetTextRunList();
                int runCount             = runList.Count;

                for (int r = 0; r < runCount; ++r)
                {
                    TextRun tt = runList[r] as TextRun;
                    if (tt == null)
                    {
                        continue;
                    }
                    //this is text run
                    if (tt.IsMeasured)
                    {
                        continue;
                    }
                    //

                    TextRunFontStyle fontStyle = tt.FontStyle;
                    //resolve to actual font face
                    TextBuffer buffer    = tt.TextBuffer;
                    char[]     rawBuffer = buffer.UnsafeGetInternalBuffer();

                    int preCount = outputGlyphPlan.Count;
                    _glyphLayout.Layout(selectedTypeface, rawBuffer, tt.StartAt, tt.Len, outputGlyphPlan);
                    int postCount = outputGlyphPlan.Count;

                    //
                    tt.SetGlyphPlanSeq(new GlyphPlanSequence(glyphPlanBuffer, preCount, postCount - preCount));
                    tt.IsMeasured = true;
                    //
                }
            }
        }
        public void DoLayout()
        {
            //----------------
            //TODO: use typography text service
            //it should be faster since it has glyph-plan cache
            //----------------

            //user can use other native methods
            //to do the layout ***

            //the following code is how-to-layout with
            //our Typography lib
            //

            //then at this step
            //we calculate span size
            //resolve each font style
            _glyphLayout.EnableComposition = true;
            _glyphLayout.EnableLigature    = true;
            int lineCount = _lines.Count;


            Typeface selectedTypeface = this.DefaultTypeface;
            float    pxscale          = selectedTypeface.CalculateScaleToPixelFromPointSize(this.FontSizeInPts);

            for (int i = 0; i < lineCount; ++i)
            {
                EditableTextLine line    = _lines[i];
                List <IRun>      runList = line.UnsageGetTextRunList();
                int runCount             = runList.Count;

                for (int r = 0; r < runCount; ++r)
                {
                    TextRun tt = runList[r] as TextRun;
                    if (tt == null)
                    {
                        continue;
                    }
                    //this is text run
                    if (tt.IsMeasured)
                    {
                        continue;
                    }
                    //

                    TextRunFontStyle fontStyle = tt.FontStyle;
                    //resolve to actual font face
                    TextBuffer buffer    = tt.TextBuffer;
                    char[]     rawBuffer = buffer.UnsafeGetInternalBuffer();


                    //TODO: review here again

                    int preCount = _outputGlyphPlan.Count;

                    _glyphLayout.Typeface = selectedTypeface;
                    _glyphLayout.Layout(rawBuffer, tt.StartAt, tt.Len);

                    _glyphLayout.GenerateUnscaledGlyphPlans(_outputGlyphPlan);


                    //use pixel-scale-layout-engine to scale to specific font size
                    //or scale it manually
                    int postCount = _outputGlyphPlan.Count;
                    //
                    tt.SetGlyphPlanSeq(new GlyphPlanSequence(_outputGlyphPlan, preCount, postCount - preCount));
                    tt.IsMeasured = true;
                    //
                }
            }
        }