-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcvtSvg.py
45 lines (36 loc) · 1.49 KB
/
cvtSvg.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
import xmltodict
with open('icons.ssvg') as fd:
doc = xmltodict.parse(fd.read())
#ff = doc['svg']['defs']['font']['glyph']
#print (ff)
print ('=============================')
for rec_no in range(len(doc['svg']['defs']['font']['glyph'])):
print("==-[" + str(rec_no) + "]-==")
name = doc['svg']['defs']['font']['glyph'][rec_no]
filename = str(rec_no)
glyph_name = ""
unicode = ""
vert_adv_y = ""
d = ""
print ('=============================')
for key, value in name.items():
if (key =='@glyph-name'):
glyph_name = " glyph-name=\"" + value + "\""
filename = value
if (key =='@unicode'):
unicode = " unicode=\"" + value + "\""
if (key =='@vert-adv-y'):
vert_adv_y = " vert_adv-y=\"" + value + "\""
if (key =='@d'):
d = " d=\"" + value + "\""
print(glyph_name)
print(unicode)
print(vert_adv_y)
#print ('=============================')
#print ("<path transform=\"scale(1, -1) translate(0, -1500)\"" +glyph_name + unicode + vert_adv_y + d + "/>")
#print ('=============================')
with open(filename + ".svg", 'w') as w:
w.write('<?xml version="1.0" standalone="no"?>\n')
w.write('<svg width="1500px" height="1500px" version="1.1" xmlns="http://www.w3.org/2000/svg">\n')
w.write("<path " + glyph_name + unicode + vert_adv_y + d + "/>")
w.write('</svg>')