From 51d7524a23be6dceb3de0f6d2835459e6ee29a01 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 3 Feb 2023 15:20:22 -0700 Subject: [PATCH] Revert "[ttGlyphSet] Must deep copy var components when instantiating" This reverts commit fe6f5bd14386d0a1f546d079f1ec38e4d2414fbf. Better fix. --- Lib/fontTools/ttLib/tables/_g_l_y_f.py | 1 + Lib/fontTools/ttLib/ttGlyphSet.py | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index eac773b4a..7689d9b12 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -2010,6 +2010,7 @@ class GlyphVarComponent(object): i += 1 self.location = newLocation + self.transform = DecomposedTransform() if self.flags & ( VarComponentFlags.HAVE_TRANSLATE_X | VarComponentFlags.HAVE_TRANSLATE_Y ): diff --git a/Lib/fontTools/ttLib/ttGlyphSet.py b/Lib/fontTools/ttLib/ttGlyphSet.py index c2521dc51..12afd4cae 100644 --- a/Lib/fontTools/ttLib/ttGlyphSet.py +++ b/Lib/fontTools/ttLib/ttGlyphSet.py @@ -3,7 +3,7 @@ from abc import ABC, abstractmethod from collections.abc import Mapping from contextlib import contextmanager -from copy import copy, deepcopy +from copy import copy from types import SimpleNamespace from fontTools.misc.fixedTools import otRound from fontTools.misc.loggingTools import deprecateFunction @@ -288,14 +288,12 @@ def _setCoordinates(glyph, coord, glyfTable): if glyph.isComposite(): assert len(coord) == len(glyph.components) - # Shallow copy is enough: all attributes that we change are scalars - glyph.components = [copy(comp) for comp in glyph.components] + glyph.components = [copy(comp) for comp in glyph.components] # Shallow copy for p, comp in zip(coord, glyph.components): if hasattr(comp, "x"): comp.x, comp.y = p elif glyph.isVarComposite(): - # Deep copy needed because we mutate comp.transform and comp.location - glyph.components = [deepcopy(comp) for comp in glyph.components] + glyph.components = [copy(comp) for comp in glyph.components] # Shallow copy for comp in glyph.components: coord = comp.setCoordinates(coord) assert not coord