Skip to content

Commit 63741b9

Browse files
committed
skip disabled custom parameters when glyphs=>ufo and minimal=True
Fixes #905
1 parent f3e43f3 commit 63741b9

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

Lib/glyphsLib/builder/custom_params.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,16 @@ def identity(value):
8484
class GlyphsObjectProxy:
8585
"""Accelerate and record access to the glyphs object's custom parameters"""
8686

87-
def __init__(self, glyphs_object, glyphs_module):
87+
def __init__(self, glyphs_object, glyphs_module, ignore_disabled=False):
8888
self._owner = glyphs_object
8989
# This is a key part to be used in UFO lib keys to be able to choose
9090
# between master and font attributes during roundtrip
9191
self.sub_key = glyphs_object.__class__.__name__ + "."
9292
self._glyphs_module = glyphs_module
9393
self._lookup = defaultdict(list)
9494
for param in glyphs_object.customParameters:
95+
if ignore_disabled and param.disabled:
96+
continue
9597
self._lookup[param.name].append(param.value)
9698
self._handled = set()
9799

@@ -1063,8 +1065,25 @@ def to_glyphs(self, glyphs, ufo):
10631065

10641066

10651067
def to_ufo_custom_params(self, ufo, glyphs_object, set_default_params=True):
1066-
# glyphs_module=None because we shouldn't instanciate any Glyphs classes
1067-
glyphs_proxy = GlyphsObjectProxy(glyphs_object, glyphs_module=None)
1068+
# glyphs_module=None because we shouldn't instanciate any Glyphs classes.
1069+
1070+
# In 'minimal' mode (enabled e.g. by fontmake when converting .glyphs => .ufo
1071+
# for compiling OpenType fonts) we treat disabled custom parameters as if
1072+
# they are absent.
1073+
# Note that the custom parameters' 'disabled' status is still not saved in the
1074+
# UFO so converting back to .glyphs will mark them as enabled.
1075+
# https://github.com/googlefonts/glyphsLib/issues/905
1076+
1077+
# `self` is normally a UFOBuilder instance, but it can be None when this
1078+
# is called by `glyphsLib.builder.instances.apply_instance_data_to_ufo`.
1079+
# The latter function is only ever used by fontmake (to apply instance custom
1080+
# parameters to interpolated instance UFOs) and never in glyphsLib's own
1081+
# glyphs=>ufo=>glyphs code, therefore we assume that when self is None,
1082+
# a 'minimal' build is desired.
1083+
ignore_disabled = getattr(self, "minimal", True)
1084+
glyphs_proxy = GlyphsObjectProxy(
1085+
glyphs_object, glyphs_module=None, ignore_disabled=ignore_disabled
1086+
)
10681087
ufo_proxy = UFOProxy(ufo)
10691088

10701089
glyphs_proxy.mark_handled(UFO_FILENAME_CUSTOM_PARAM)

0 commit comments

Comments
 (0)