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 committed Oct 3, 2024
1 parent 63741b9 commit 51c9aad
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 @@ -1370,10 +1370,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", disabled=False):
self.name = name
self.value = value
self.disabled = False
self.disabled = disabled

def __repr__(self):
return f"<{self.__class__.__name__} {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 @@ -44,6 +44,9 @@
from glyphsLib.classes import GSFont, GSFontMaster, GSCustomParameter, GSGlyph, GSLayer
from glyphsLib.types import parse_datetime

import pytest


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


Expand Down Expand Up @@ -734,3 +737,28 @@ def test_mutiple_params(ufo_module):

assert instance.customParameters[0].value == "ccmp;sub space by space;"
assert instance.customParameters[1].value == "liga;sub space space by space;"


@pytest.mark.parametrize("disabled", [False, True])
def test_disabled_glyphOrder_custom_params(ufo_module, disabled):
# 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, disabled=disabled)
)

ufo = to_ufos(font, ufo_module=ufo_module, minimal=True)[0]

if disabled:
assert ufo.lib["public.glyphOrder"] == implicit_glyph_order
else:
assert ufo.lib["public.glyphOrder"] == custom_glyph_order

0 comments on commit 51c9aad

Please sign in to comment.