Project

General

Profile

Revision 188

many changes

View differences:

split_font.py
1 1
import os
2
import sys
2 3
import glob
3 4
from PIL import Image
4 5

  
5
im = Image.open("Consolas.png")
6
f = sys.argv[1]
7
WCHAR = int(sys.argv[2])
8
HCHAR = int(sys.argv[3])
9
Nw    = int(sys.argv[4])
10
Nh    = int(sys.argv[5])
11
i     = int(sys.argv[6])
6 12

  
13
os.system("mkdir -p %s/png"%f)
14
im = Image.open("%s/%s.png"%(f,f))
7 15
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 16
for h in range(Nh):
23
    t = int(H/Nh)*h
24
    b = int(H/Nh)*(h+1)
17
    t = HCHAR*h
18
    b = HCHAR*(h+1)
25 19
    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)
20
        l = WCHAR*w
21
        r = WCHAR*(w+1)
30 22
        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

  
23
        im1.save("%s/png/ascii%03d.png"%(f,i))
41 24
        i += 1
42

  
43
os.system('sed -i "s/black/#000000/g" xpm/*.xpm')

Also available in: Unified diff