From adf3654b33feafaed1741f8e27c3837c6e12715c Mon Sep 17 00:00:00 2001 From: Rasmus Andersson Date: Sat, 15 Oct 2022 16:23:56 -0700 Subject: workaround for bug in glyphslib/fontmake that generates UFO glyphs with fractional widths. Closes #508 --- misc/tools/postprocess_instance_ufo.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'misc/tools/postprocess_instance_ufo.py') diff --git a/misc/tools/postprocess_instance_ufo.py b/misc/tools/postprocess_instance_ufo.py index 26d29aa96..37be67d0f 100644 --- a/misc/tools/postprocess_instance_ufo.py +++ b/misc/tools/postprocess_instance_ufo.py @@ -15,12 +15,27 @@ def ufo_set_wws(ufo): ufo.info.openTypeNameWWSSubfamilyName = subfamily +# See https://github.com/rsms/inter/issues/508 +# TODO: Remove when https://github.com/googlefonts/glyphsLib/issues/821 is fixed +def fix_fractional_advance_width(ufo): + for g in ufo: + g.width = round(g.width) + + def main(argv): ufo_file = argv[1] - if ufo_file.find("Display") == -1: - return # skip fonts of "default" family + + # TODO: Uncomment when https://github.com/googlefonts/glyphsLib/issues/821 is fixed + # if ufo_file.find("Display") == -1: + # return # skip fonts of "default" family + ufo = defcon.Font(ufo_file) - ufo_set_wws(ufo) + + if ufo_file.find("Display") != -1: + ufo_set_wws(ufo) + + fix_fractional_advance_width(ufo) + ufo.save(ufo_file) -- cgit v1.2.3