From c79709096b7386060be4be7766537bea6d464c4a Mon Sep 17 00:00:00 2001 From: Rasmus Andersson Date: Wed, 5 Oct 2022 10:11:10 -0700 Subject: Workaround for bug in fontmake causing bad weight metadata Workaround for bug in fontmake which caused incorrect weight metadata in static fonts. See https://github.com/googlefonts/fontmake/issues/943 Related to #498 --- misc/tools/postprocess-designspace.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'misc') diff --git a/misc/tools/postprocess-designspace.py b/misc/tools/postprocess-designspace.py index 51ad5ab85..f1b68d471 100644 --- a/misc/tools/postprocess-designspace.py +++ b/misc/tools/postprocess-designspace.py @@ -72,11 +72,12 @@ def set_ufo_filter(ufo, **filter_dict): return filters.append(filter_dict) -def update_source_ufo(ufo_file, glyphs_to_decompose): - print("update %s" % os.path.basename(ufo_file)) +def update_source_ufo(ufo_file, weight, glyphs_to_decompose): + print(f"update {os.path.basename(ufo_file)} (weight={weight})") ufo = defcon.Font(ufo_file) update_version(ufo) set_ufo_filter(ufo, name="decomposeComponents", include=glyphs_to_decompose) + ufo.info.openTypeOS2WeightClass = int(weight) ufo.save(ufo_file) def update_sources(designspace): @@ -84,9 +85,10 @@ def update_sources(designspace): #print("glyphs marked to be decomposed: %s" % ', '.join(glyphs_to_decompose)) sources = [source for source in designspace.sources] # sources = [s for s in sources if s.name == "Inter Thin"] # DEBUG - source_files = list(set([s.path for s in sources])) + source_files = list(set([(s.path, s.location["Weight"]) for s in sources])) with Pool(len(source_files)) as p: - p.starmap(update_source_ufo, [(file, glyphs_to_decompose) for file in source_files]) + p.starmap(update_source_ufo, + [(t[0], t[1], glyphs_to_decompose) for t in source_files]) return designspace def main(argv): -- cgit v1.2.3