@@ -84,14 +84,16 @@ def identity(value):
84
84
class GlyphsObjectProxy :
85
85
"""Accelerate and record access to the glyphs object's custom parameters"""
86
86
87
- def __init__ (self , glyphs_object , glyphs_module ):
87
+ def __init__ (self , glyphs_object , glyphs_module , ignore_disabled = False ):
88
88
self ._owner = glyphs_object
89
89
# This is a key part to be used in UFO lib keys to be able to choose
90
90
# between master and font attributes during roundtrip
91
91
self .sub_key = glyphs_object .__class__ .__name__ + "."
92
92
self ._glyphs_module = glyphs_module
93
93
self ._lookup = defaultdict (list )
94
94
for param in glyphs_object .customParameters :
95
+ if ignore_disabled and param .disabled :
96
+ continue
95
97
self ._lookup [param .name ].append (param .value )
96
98
self ._handled = set ()
97
99
@@ -1063,8 +1065,25 @@ def to_glyphs(self, glyphs, ufo):
1063
1065
1064
1066
1065
1067
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
+ )
1068
1087
ufo_proxy = UFOProxy (ufo )
1069
1088
1070
1089
glyphs_proxy .mark_handled (UFO_FILENAME_CUSTOM_PARAM )
0 commit comments