root / proj / font / split_font.py @ 183
History | View | Annotate | Download (779 Bytes)
1 |
import os |
---|---|
2 |
import glob |
3 |
from PIL import Image |
4 |
|
5 |
im = Image.open("Consolas.png")
|
6 |
|
7 |
W, H = im.size |
8 |
|
9 |
Nw = 16
|
10 |
Nh = 6
|
11 |
|
12 |
i = 32
|
13 |
|
14 |
includes = ""
|
15 |
lst = ""
|
16 |
|
17 |
for j in range(i): |
18 |
if lst != "": lst += "," |
19 |
lst += "NULL"
|
20 |
|
21 |
|
22 |
for h in range(Nh): |
23 |
t = int(H/Nh)*h
|
24 |
b = int(H/Nh)*(h+1) |
25 |
for w in range(Nw): |
26 |
#l = int((W*w)/Nw)
|
27 |
#r = int((W*(w+1))/Nw)
|
28 |
l = 59*w
|
29 |
r = 59*(w+1) |
30 |
im1 = im.crop((l,t,r,b)) |
31 |
im1.save("png/ascii%03d.png"%i)
|
32 |
os.system("convert png/ascii%03d.png xpm/ascii%03d.xpm"%(i,i))
|
33 |
|
34 |
includes += '#include "%03d.xpm"\n'%i
|
35 |
if lst != "": lst += "," |
36 |
lst += "%03d_xpm"%i
|
37 |
|
38 |
#DEV
|
39 |
os.system("rm png/ascii%03d.png"%i)
|
40 |
|
41 |
i += 1
|
42 |
|
43 |
os.system('sed -i "s/black/#000000/g" xpm/*.xpm')
|