From 2cb8d533d2b07ea0cd40a6125f0643ba30f314ac Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 14 Feb 2024 04:08:45 +0200 Subject: [PATCH] Pass MATH userData in minimal mode as well --- Lib/glyphsLib/builder/glyph.py | 4 ++-- Lib/glyphsLib/builder/user_data.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/glyphsLib/builder/glyph.py b/Lib/glyphsLib/builder/glyph.py index b9f60abb3..ac4616fd5 100644 --- a/Lib/glyphsLib/builder/glyph.py +++ b/Lib/glyphsLib/builder/glyph.py @@ -142,9 +142,9 @@ def to_ufo_glyph(self, ufo_glyph, layer, glyph, do_color_layers=True): # noqa: self.to_ufo_guidelines(ufo_glyph, layer) # .guidelines self.to_ufo_glyph_background(ufo_glyph, layer) # below self.to_ufo_annotations(ufo_glyph, layer) # .annotations - self.to_ufo_glyph_user_data(ufo_font, glyph) # .user_data - self.to_ufo_layer_user_data(ufo_glyph, layer) # .user_data self.to_ufo_smart_component_axes(ufo_glyph, glyph) # .components + self.to_ufo_glyph_user_data(ufo_font, glyph) # .user_data + self.to_ufo_layer_user_data(ufo_glyph, layer) # .user_data # Optimization: profiling glyphs2ufo of NotoSans-MM.glyphs (6000 glyphs) on a Mac # mini late 2014, Python 3.6.8, revealed that a whopping 17% of the time was spent diff --git a/Lib/glyphsLib/builder/user_data.py b/Lib/glyphsLib/builder/user_data.py index 3b1cae614..aea376909 100644 --- a/Lib/glyphsLib/builder/user_data.py +++ b/Lib/glyphsLib/builder/user_data.py @@ -72,6 +72,8 @@ def to_ufo_glyph_user_data(self, ufo, glyph): ufo.lib.setdefault(GLYPHS_MATH_VARIANTS_KEY, {})[glyph.name] = dict( mathData[GLYPHS_MATH_VARIANTS_KEY] ) + if self.minimal: + return otherData = {k: v for k, v in glyph.userData.items() if k not in mathData} key = GLYPH_USER_DATA_KEY + "." + glyph.name if otherData: @@ -101,6 +103,8 @@ def to_ufo_layer_lib(self, master, ufo, ufo_layer): def to_ufo_layer_user_data(self, ufo_glyph, layer): user_data = layer.userData for key in user_data.keys(): + if self.minimal and not key.startswith(GLYPHS_MATH_PREFIX): + continue if _user_data_has_no_special_meaning(key): ufo_glyph.lib[key] = user_data[key]