blob: 37be67d0f68b5b04f0ae654d5c87730700e63187 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import sys
import defcon
def ufo_set_wws(ufo):
# Fix missing WWS entries for Display fonts:
# See https://github.com/googlefonts/glyphsLib/issues/820
subfamily = ufo.info.styleName
if subfamily.find("Display") == -1:
return
subfamily = subfamily[len("Display"):].strip()
if subfamily == "":
# "Display" -> "Regular"
subfamily = "Regular"
ufo.info.openTypeNameWWSFamilyName = "Inter Display"
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]
# 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)
if ufo_file.find("Display") != -1:
ufo_set_wws(ufo)
fix_fractional_advance_width(ufo)
ufo.save(ufo_file)
if __name__ == '__main__':
main(sys.argv)
|