public float GetTypographicWidth(MathFont <char> font, AttributedGlyphRun <TFont, TGlyph> run) { int effectiveLength = GetEffectiveLength(run.Glyphs.ToArray()); float width = font.PointSize * effectiveLength * WidthPerCharacterPerFontSize + run.KernedGlyphs.Sum(g => g.KernAfterGlyph); return(width); }
public (float[] Advances, float Total) GetAdvancesForGlyphs(MathFont <TGlyph> font, TGlyph[] glyphs) { var r = new float[glyphs.Length]; var total = 0f; for (int i = 0; i < glyphs.Length; i++) { total += r[i] = GetEffectiveLength(glyphs[i]) * font.PointSize * WidthPerCharacterPerFontSize; } return(r, total); }
public void TestGlyphBoundsWithM() { string america = "America"; MathFont <TGlyph> font = new MathFont <TGlyph>(10); var provider = new TestGlyphBoundsProvider(); var glyphRun = new AttributedGlyphRun <MathFont <TGlyph>, TGlyph> { Font = font, KernedGlyphs = america.ToCharArray().Select(c => new KernedGlyph <char>(c)).ToArray(), }; var width = provider.GetTypographicWidth(font, glyphRun); Assertions.ApproximatelyEqual(width, 40, 0.01); }
public int GetUnitsPerEm(MathFont <char> font) => 1000;
public char[] FindGlyphs(MathFont <char> font, string str) => str.ToArray();
public char FindGlyphForCharacterAtIndex(MathFont <char> font, int index, string str) { return(str[index]); }