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
This commit is contained in:
parent
bd5bdd3f19
commit
c79709096b
1 changed files with 6 additions and 4 deletions
|
|
@ -72,11 +72,12 @@ def set_ufo_filter(ufo, **filter_dict):
|
||||||
return
|
return
|
||||||
filters.append(filter_dict)
|
filters.append(filter_dict)
|
||||||
|
|
||||||
def update_source_ufo(ufo_file, glyphs_to_decompose):
|
def update_source_ufo(ufo_file, weight, glyphs_to_decompose):
|
||||||
print("update %s" % os.path.basename(ufo_file))
|
print(f"update {os.path.basename(ufo_file)} (weight={weight})")
|
||||||
ufo = defcon.Font(ufo_file)
|
ufo = defcon.Font(ufo_file)
|
||||||
update_version(ufo)
|
update_version(ufo)
|
||||||
set_ufo_filter(ufo, name="decomposeComponents", include=glyphs_to_decompose)
|
set_ufo_filter(ufo, name="decomposeComponents", include=glyphs_to_decompose)
|
||||||
|
ufo.info.openTypeOS2WeightClass = int(weight)
|
||||||
ufo.save(ufo_file)
|
ufo.save(ufo_file)
|
||||||
|
|
||||||
def update_sources(designspace):
|
def update_sources(designspace):
|
||||||
|
|
@ -84,9 +85,10 @@ def update_sources(designspace):
|
||||||
#print("glyphs marked to be decomposed: %s" % ', '.join(glyphs_to_decompose))
|
#print("glyphs marked to be decomposed: %s" % ', '.join(glyphs_to_decompose))
|
||||||
sources = [source for source in designspace.sources]
|
sources = [source for source in designspace.sources]
|
||||||
# sources = [s for s in sources if s.name == "Inter Thin"] # DEBUG
|
# 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:
|
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
|
return designspace
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
|
|
||||||
Reference in a new issue