-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimp.py
38 lines (33 loc) · 946 Bytes
/
imp.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
from os import listdir
import re
import fontforge
import os.path
inpath = "/home/nekoyasha/Desktop/nekotoba2/"
exp = re.compile(r"U\+(.*)\.svg")
af = fontforge.activeFont()
print af
bunch = listdir(inpath)
for f in bunch:
m = exp.match(f)
if m:
print f, m.group(1)
g = af.createChar(int(m.group(1),16))
print g
if not g.isWorthOutputting():
p = os.path.join(inpath,f)
print p
g.importOutlines(p)
g.simplify(2.4, ("ignoreslopes", "ignoreextrema", "smoothcurves"))
g.addExtrema("only_good_rm")
g.removeOverlap()
g.correctDirection()
g.round()
#remove small splines here
g.addExtrema("all")
g.canonicalContours()
g.round()
g.removeOverlap()
g.round()
#fix width here
g.width = af.em
g.validate(True)