/// <summary> /// read GlyphPlan latest layout output /// </summary> private static void ReadOutput(GlyphLayout glyphLayout, UnscaledGlyphPlanList outputGlyphPlanList) { Typeface typeface = glyphLayout.Typeface; var glyphPositions = glyphLayout._glyphPositions; //3.read back int finalGlyphCount = glyphPositions.Count; int cx = 0; short cy = 0; PositionTechnique posTech = glyphLayout.PositionTechnique; ushort prev_index = 0; for (int i = 0; i < finalGlyphCount; ++i) { GlyphPos glyphPos = glyphPositions[i]; switch (posTech) { default: throw new NotSupportedException(); case PositionTechnique.None: outputGlyphPlanList.Append(new UnscaledGlyphPlan( 0, glyphPos.glyphIndex, glyphPos.advanceW, cx, cy)); break; case PositionTechnique.OpenFont: outputGlyphPlanList.Append(new UnscaledGlyphPlan( 0, glyphPos.glyphIndex, glyphPos.advanceW, cx + glyphPos.xoffset, (short)(cy + glyphPos.yoffset))); break; case PositionTechnique.Kerning: if (i > 0) { cx += typeface.GetKernDistance(prev_index, glyphPos.glyphIndex); } outputGlyphPlanList.Append(new UnscaledGlyphPlan( 0, prev_index = glyphPos.glyphIndex, glyphPos.advanceW, cx, cy)); break; } cx += glyphPos.advanceW; } }
public IUnscaledGlyphPlanList StringToGlyphPlanList(string s) { m_layout.Layout(s.ToCharArray(), 0, s.Length); var l = new UnscaledGlyphPlanList(); foreach (var g in m_layout.GetUnscaledGlyphPlanIter()) { l.Append(g); } return(l); }