~ubuntu-branches/ubuntu/wily/python-imaging/wily

« back to all changes in this revision

Viewing changes to .pc/changes-1.1.7.diff/Scripts/pilfont.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-01-31 20:49:20 UTC
  • mfrom: (1.1.4)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130131204920-7tnuhqhlsqdza4c2
Rewrite build dependencies to allow cross builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# The Python Imaging Library
 
3
# $Id$
 
4
#
 
5
# PIL raster font compiler
 
6
#
 
7
# history:
 
8
# 1997-08-25 fl   created
 
9
# 2002-03-10 fl   use "from PIL import"
 
10
#
 
11
 
 
12
VERSION = "0.4"
 
13
 
 
14
import site
 
15
import glob, os, sys
 
16
 
 
17
# drivers
 
18
from PIL import BdfFontFile
 
19
from PIL import PcfFontFile
 
20
 
 
21
if len(sys.argv) <= 1:
 
22
    print "PILFONT", VERSION, "-- PIL font compiler."
 
23
    print
 
24
    print "Usage: pilfont fontfiles..."
 
25
    print
 
26
    print "Convert given font files to the PIL raster font format."
 
27
    print "This version of pilfont supports X BDF and PCF fonts."
 
28
    sys.exit(1)
 
29
 
 
30
files = []
 
31
for f in sys.argv[1:]:
 
32
    files = files + glob.glob(f)
 
33
 
 
34
for f in files:
 
35
 
 
36
    print f + "...",
 
37
 
 
38
    try:
 
39
 
 
40
        fp = open(f, "rb")
 
41
 
 
42
        try:
 
43
            p = PcfFontFile.PcfFontFile(fp)
 
44
        except SyntaxError:
 
45
            fp.seek(0)
 
46
            p = BdfFontFile.BdfFontFile(fp)
 
47
 
 
48
        p.save(f)
 
49
 
 
50
    except (SyntaxError, IOError):
 
51
        print "failed"
 
52
 
 
53
    else:
 
54
        print "OK"