summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2022-10-05 20:11:10 +0300
committerRasmus Andersson <rasmus@notion.se>2022-10-05 20:11:16 +0300
commitc79709096b7386060be4be7766537bea6d464c4a (patch)
tree3b46b09bca0f00c63330e2f9901adfc8bac596d7
parentbd5bdd3f19d00654811e55b8ead27753abe548b9 (diff)
downloadinter-c79709096b7386060be4be7766537bea6d464c4a.tar.xz
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
-rw-r--r--misc/tools/postprocess-designspace.py10
1 files changed, 6 insertions, 4 deletions
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):