In FontRun.UpdateOverhang() (FontRun.cs line 521), the glyph pointer passed to GetGlyphWidths uses Start (the code point index in the text block) instead of Glyphs.Start (the offset into the underlying glyph array).
// Current (wrong):
paint.GetGlyphWidths((IntPtr)(pGlyphs + Start), sizeof(ushort) * Glyphs.Length, out var bounds);
// Should be:
paint.GetGlyphWidths((IntPtr)(pGlyphs + Glyphs.Start), sizeof(ushort) * Glyphs.Length, out var bounds);
Start is the code point index of this font run in the overall text, while Glyphs.Start is the actual offset into the glyph buffer. These differ whenever glyph count != code point count (ligatures, combining marks, surrogate pairs, complex scripts).
This causes incorrect overhang/bounds calculations, affecting MeasuredOverhang results particularly with non-Latin text or fonts with ligatures.
In
FontRun.UpdateOverhang()(FontRun.cs line 521), the glyph pointer passed toGetGlyphWidthsusesStart(the code point index in the text block) instead ofGlyphs.Start(the offset into the underlying glyph array).Startis the code point index of this font run in the overall text, whileGlyphs.Startis the actual offset into the glyph buffer. These differ whenever glyph count != code point count (ligatures, combining marks, surrogate pairs, complex scripts).This causes incorrect overhang/bounds calculations, affecting
MeasuredOverhangresults particularly with non-Latin text or fonts with ligatures.