[removeOverlaps] Fix CFF CharString width

The width argument of `T2CharStringPen()` is inserted directly into the
CharString program, so it must be relative to Private.nominalWidthX, but
CharString.width is a calculated absolute value.

Some implementations, notably Adobe’s, will use the width from the CFF
CharString instead of the one from hmtx table.

Fixes https://github.com/fonttools/fonttools/issues/3658
This commit is contained in:
Khaled Hosny 2024-10-12 01:22:17 +03:00
parent f7ecc6fe65
commit 40b525c1e3

View File

@ -87,7 +87,8 @@ def ttfGlyphFromSkPath(path: pathops.Path) -> _g_l_y_f.Glyph:
def _charString_from_SkPath(
path: pathops.Path, charString: T2CharString
) -> T2CharString:
t2Pen = T2CharStringPen(width=charString.width, glyphSet=None)
width = charString.width - charString.private.nominalWidthX
t2Pen = T2CharStringPen(width=width, glyphSet=None)
path.draw(t2Pen)
return t2Pen.getCharString(charString.private, charString.globalSubrs)