-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmakefont.py
36 lines (30 loc) · 1.08 KB
/
makefont.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
import os
import fontforge
import psMat;
FONTNAME = 'vscode-adjusted-icons'
DIR = './icons'
if __name__ == '__main__':
font = fontforge.font()
font.fontname = FONTNAME
font.familyname = FONTNAME
font.copyright = 'Some of symbols are imported from FontAwesome SVGs'
font.fullname = FONTNAME
try:
for svg_file in os.listdir(DIR):
if svg_file.find('.svg') == -1: # is not a svg file
continue
g = font.createChar(int(svg_file.split('-')[0], base=16))
print(svg_file)
g.importOutlines(
os.path.join(DIR, svg_file), ('removeoverlap', 'correctdir'))
g.removeOverlap()
move_mat = psMat.translate( -100,0 )
g.transform(move_mat)
scale_mat = psMat.scale(1.1)
g.transform(scale_mat)
except ValueError:
print('"%s" is not a valid file name.' % svg_file)
print('File name should be in format "hexnumber-name.svg". e.g. "ff5a-search.svg"')
except Exception as e:
raise e
font.generate('%s.ttf' % FONTNAME)