Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
 public int GetUnitsPerEm(MathFont <char> font) => 1000;
Example #5
0
 public char[] FindGlyphs(MathFont <char> font, string str) => str.ToArray();
Example #6
0
 public char FindGlyphForCharacterAtIndex(MathFont <char> font, int index, string str)
 {
     return(str[index]);
 }