Project

General

Profile

Statistics
| Revision:

root / proj / font / split_font.py @ 180

History | View | Annotate | Download (475 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

    
15

    
16
for h in range(Nh):
17
    t = int(H/Nh)*h
18
    b = int(H/Nh)*(h+1)
19
    for w in range(Nw):
20
        #l = int((W*w)/Nw)
21
        #r = int((W*(w+1))/Nw)
22
        l = 59*w
23
        r = 59*(w+1)
24
        im1 = im.crop((l,t,r,b))
25
        im1.save("%03d.png"%i)
26
        os.system("convert %03d.png xpm/%03d.xpm"%(i,i))
27
        os.system("rm %03d.png"%i)
28
        i += 1