From 40b525c1e3cc20b4b64004b8e3224a67adc2adf1 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sat, 12 Oct 2024 01:22:17 +0300 Subject: [PATCH] [removeOverlaps] Fix CFF CharString width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Lib/fontTools/ttLib/removeOverlaps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/fontTools/ttLib/removeOverlaps.py b/Lib/fontTools/ttLib/removeOverlaps.py index 312b56b29..4ab8a1a64 100644 --- a/Lib/fontTools/ttLib/removeOverlaps.py +++ b/Lib/fontTools/ttLib/removeOverlaps.py @@ -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)