From b331e2ea5935b6786309d02a75f058f87bb5df3a Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 3 Oct 2024 14:11:11 +0100 Subject: [PATCH] add test for disabled custom parameter --- Lib/glyphsLib/classes.py | 4 ++-- tests/builder/custom_params_test.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Lib/glyphsLib/classes.py b/Lib/glyphsLib/classes.py index 7d0b95986..a922c49db 100755 --- a/Lib/glyphsLib/classes.py +++ b/Lib/glyphsLib/classes.py @@ -1868,10 +1868,10 @@ def _serialize_to_plist(self, writer): _CUSTOM_DICT_PARAMS = frozenset("GASP Table") - def __init__(self, name="New Value", value="New Parameter"): + def __init__(self, name="New Value", value="New Parameter", active=True): self.name = name self.value = value - self.active = True + self.active = active def __repr__(self): return f"<{self.__class__.__name__} {hex(id(self))}> {self.name}: {self._value}" diff --git a/tests/builder/custom_params_test.py b/tests/builder/custom_params_test.py index 2cc1dfae6..fdd052d02 100644 --- a/tests/builder/custom_params_test.py +++ b/tests/builder/custom_params_test.py @@ -49,6 +49,9 @@ ) from glyphsLib.types import parse_datetime +import pytest + + DATA = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data") @@ -825,3 +828,28 @@ def test_multi_customparameter_rt(ufo_module): ) == 2 ) + + +@pytest.mark.parametrize("active", [True, False]) +def test_disabled_glyphOrder_custom_params(ufo_module, active): + # With minimal=True, 'disabled' custom parameters should be ignored + # https://github.com/googlefonts/glyphsLib/issues/905 + # https://github.com/googlefonts/fontc/issues/985 + font = GSFont() + font.masters.append(GSFontMaster()) + + implicit_glyph_order = [".notdef", "A", "B", "C"] + for glyph_name in implicit_glyph_order: + font.glyphs.append(GSGlyph(glyph_name)) + + custom_glyph_order = [".notdef", "C", "B", "A"] + font.customParameters.append( + GSCustomParameter("glyphOrder", custom_glyph_order, active=active) + ) + + ufo = to_ufos(font, ufo_module=ufo_module, minimal=True)[0] + + if active: + assert ufo.lib["public.glyphOrder"] == custom_glyph_order + else: + assert ufo.lib["public.glyphOrder"] == implicit_glyph_order