diff --git a/Lib/glyphsLib/builder/instances.py b/Lib/glyphsLib/builder/instances.py index 7d518da93..89615b2be 100644 --- a/Lib/glyphsLib/builder/instances.py +++ b/Lib/glyphsLib/builder/instances.py @@ -389,8 +389,10 @@ def apply_instance_data_to_ufo(ufo, instance, designspace): Returns: None. """ - set_weight_class(ufo, designspace, instance) - set_width_class(ufo, designspace, instance) + if any(axis.tag == "wght" for axis in designspace.axes): + set_weight_class(ufo, designspace, instance) + if any(axis.tag == "wdth" for axis in designspace.axes): + set_width_class(ufo, designspace, instance) glyphs_instance = InstanceDescriptorAsGSInstance(instance) to_ufo_custom_params(None, ufo, glyphs_instance) diff --git a/tests/builder/instances_test.py b/tests/builder/instances_test.py index ec31ef58c..21bea228f 100644 --- a/tests/builder/instances_test.py +++ b/tests/builder/instances_test.py @@ -67,8 +67,17 @@ def test_apply_instance_data(tmpdir, instance_names): assert len(ufos) == len(test_instances) for ufo in ufos: - assert ufo.info.openTypeOS2WeightClass is not None - assert ufo.info.openTypeOS2WidthClass is not None + assert ufo.info.openTypeOS2WeightClass in { + 100, + 200, + 300, + 400, + 500, + 700, + 900, + 357, + } + assert ufo.info.openTypeOS2WidthClass is None # GlyphsUnitTestSans is wght only def test_reexport_apply_instance_data():