From 77add05f7fbce736b1ad8ee834c17e227c034372 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Tue, 23 Apr 2024 08:51:01 +0200 Subject: [PATCH] Don't emit addVarComponent() if the component references the parent glyph (special case) --- Lib/fontTools/ttLib/ttGlyphSet.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Lib/fontTools/ttLib/ttGlyphSet.py b/Lib/fontTools/ttLib/ttGlyphSet.py index 6267e7880..e4f035ad6 100644 --- a/Lib/fontTools/ttLib/ttGlyphSet.py +++ b/Lib/fontTools/ttLib/ttGlyphSet.py @@ -355,11 +355,17 @@ class _TTGlyphVARC(_TTGlyph): reset = comp.flags & VarComponentFlags.RESET_UNSPECIFIED_AXES with self.glyphSet.glyphSet.pushLocation(location, reset): with self.glyphSet.pushLocation(location, reset): - try: - pen.addVarComponent( - comp.glyphName, transform, self.glyphSet.rawLocation - ) - except AttributeError: + shouldDecompose = self.name == comp.glyphName + + if not shouldDecompose: + try: + pen.addVarComponent( + comp.glyphName, transform, self.glyphSet.rawLocation + ) + except AttributeError: + shouldDecompose = True + + if shouldDecompose: t = transform.toTransform() compGlyphSet = ( self.glyphSet