Skip to content

Commit

Permalink
add test for disabled custom parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
anthrotype authored and schriftgestalt committed Oct 23, 2024
1 parent 63d7896 commit b331e2e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/glyphsLib/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
28 changes: 28 additions & 0 deletions tests/builder/custom_params_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
)
from glyphsLib.types import parse_datetime

import pytest


DATA = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")


Expand Down Expand Up @@ -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

0 comments on commit b331e2e

Please sign in to comment.