-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbaseline.py
60 lines (34 loc) · 1.06 KB
/
baseline.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
import pathlib
def open_font(path: str):
font = fontforge.open(path)
return font
def operate_font(font: fontforge.font):
print(font.hhea_ascent, font.hhea_descent, font.hhea_linegap)
print(font.os2_typoascent, font.os2_typodescent, font.os2_typolinegap)
print(font.os2_winascent, font.os2_windescent)
font.hhea_ascent = font.os2_winascent
font.hhea_descent = -font.os2_windescent
font.hhea_linegap = 0
font.os2_typoascent = font.os2_winascent
font.os2_typodescent = -font.os2_windescent
font.os2_typolinegap = 0
def get_subtitle():
filename = os.path.basename(__file__)
subtitle = os.path.splitext(filename)[0]
return subtitle
def operate_arg(arg: str):
path = arg
font = open_font(path)
operate_font(font)
subtitle = get_subtitle()
filename = os.path.basename(path)
subtitlePath = pathlib.Path(subtitle)
subtitlePath.mkdir(exist_ok=True)
filePath = subtitlePath.joinpath(filename)
filepath = str(filePath)
font.generate(filepath)
if __name__ == '__main__':
arg_list = sys.argv[1:]
for arg in arg_list:
operate_arg(arg)