Skip to content

Commit

Permalink
Merge pull request #556 from googlefonts/apply_instance_data-only-app…
Browse files Browse the repository at this point in the history
…ly-when-axis-present

apply_instance_data: only apply OS/2 wght/wdth class when corresponding axis exists
  • Loading branch information
madig authored Sep 17, 2019
2 parents af5ab0b + cc0e88d commit a43ad25
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Lib/glyphsLib/builder/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 11 additions & 2 deletions tests/builder/instances_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit a43ad25

Please sign in to comment.