-
Notifications
You must be signed in to change notification settings - Fork 0
/
fontforge_scripts.txt
61 lines (46 loc) · 1.91 KB
/
fontforge_scripts.txt
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
61
import logging
# 配置日志格式和级别
logging.basicConfig(filename='c:\log1.txt', level=logging.INFO)
# change all fonts vertical center
startglyph = 11904
endglyph = 1114370
thisfont = fontforge.activeFont()
# 外层循环每次处理10000个字符的范围
chunk_size = 10000
for outer_start in range(startglyph, endglyph + 1, chunk_size):
outer_end = min(outer_start + chunk_size - 1, endglyph)
for i in range(outer_start, outer_end + 1):
try:
ytop = thisfont[i].boundingBox()[-1] # counted from baseline, excluding descent!
ybot = thisfont[i].boundingBox()[1] # same note as above
xtop = thisfont[i].boundingBox()[2]
xbot = thisfont[i].boundingBox()[0]
translation_x = (thisfont.ascent - thisfont.descent - (xtop + xbot)) / 2
translation_y = (thisfont.ascent - thisfont.descent - (ytop + ybot)) / 2
if translation_x != 0 and translation_y != 0:
thisfont[i].transform(psMat.translate(translation_x, translation_y))
logging.info("%d complete", i)
else:
logging.info("%d no change", i)
except Exception as e:
logging.info("%d Error skip", i)
logging.info("all complete.")
thisfont = fontforge.activeFont()
i=19982
ytop = thisfont[i].boundingBox()[-1] # counted from baseline, excluding descent!
ybot = thisfont[i].boundingBox()[1] # same note as above
xtop = thisfont[i].boundingBox()[2]
xbot = thisfont[i].boundingBox()[0]
translation_x = (thisfont.ascent - thisfont.descent - (xtop + xbot)) / 2
translation_y = (thisfont.ascent - thisfont.descent - (ytop + ybot)) / 2
thisfont[i].transform(psMat.translate(translation_x, translation_y))
#fontforge scripts
select
Open('C:\\Users\\Administrator\\Documents\\LXGWWenKaiMonoGB-Light-bruce.sfd');
Select(0x2e80,0x110102);
Rotate(90)
CenterInWidth();
Select(12296,12315)
Rotate(-90)
Save();
Quit(0);