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;
                    //
                }
            }
        }
Exemplo n.º 2
0
 public GlyphPlanSequence(GlyphPlanBuffer glyphBuffer, int startAt, int len)
 {
     this.glyphBuffer = glyphBuffer;
     this.startAt     = startAt;
     this.len         = (ushort)len;
 }
Exemplo n.º 3
0
 public static GlyphPlanList UnsafeGetInteralGlyphPlanList(GlyphPlanSequence planSeq)
 {
     return(GlyphPlanBuffer.UnsafeGetGlyphPlanList(planSeq.glyphBuffer));
 }
Exemplo n.º 4
0
 public static GlyphPlanList UnsafeGetGlyphPlanList(GlyphPlanBuffer buffer)
 {
     return(buffer._glyphPlans);
 }