fix: scale SUP/SUB underline to match 50%-scaled glyphs (#2255)

This commit is contained in:
SurprisedDuck
2026-06-06 18:55:47 -04:00
committed by GitHub
parent 67936cb3af
commit fad1a801a4
+7
View File
@@ -78,6 +78,13 @@ void TextBlock::render(const GfxRenderer& renderer, const int fontId, const int
underlineWidth = visibleWidth;
}
// SUP/SUB words are rendered at 50% glyph scale (see the baseline comment
// above and drawText), but getTextWidth reports the full-size width, so the
// underline would be drawn ~2x too long. Halve it to match the scaled glyphs.
if ((currentStyle & (EpdFontFamily::SUP | EpdFontFamily::SUB)) != 0) {
underlineWidth = (underlineWidth + 1) / 2;
}
renderer.drawLine(startX, underlineY, startX + underlineWidth, underlineY, true);
}
}