Fredrik Lundh is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

effbot / pil-2009-raclette http://effbot.org/zone/pil-index.htm

Work repository for PIL 1.1.7 and beyond. The "default" branch should be fairly solid, the other branches less so. For production use, see the pil-117 repository.

Clone this repository (size: 1.6 MB): HTTPS / SSH
hg clone https://bitbucket.org/effbot/pil-2009-raclette
hg clone ssh://hg@bitbucket.org/effbot/pil-2009-raclette

pil-2009-raclette / Scripts / pilfont.py

#
# The Python Imaging Library
# $Id: pilfont.py 2134 2004-10-06 08:55:20Z fredrik $
#
# PIL raster font compiler
#
# history:
# 1997-08-25 fl   created
# 2002-03-10 fl   use "from PIL import"
#

VERSION = "0.4"

import site
import glob, os, sys

# drivers
from PIL import BdfFontFile
from PIL import PcfFontFile

if len(sys.argv) <= 1:
    print "PILFONT", VERSION, "-- PIL font compiler."
    print
    print "Usage: pilfont fontfiles..."
    print
    print "Convert given font files to the PIL raster font format."
    print "This version of pilfont supports X BDF and PCF fonts."
    sys.exit(1)

files = []
for f in sys.argv[1:]:
    files = files + glob.glob(f)

for f in files:

    print f + "...",

    try:

        fp = open(f, "rb")

        try:
            p = PcfFontFile.PcfFontFile(fp)
        except SyntaxError:
            fp.seek(0)
            p = BdfFontFile.BdfFontFile(fp)

        p.save(f)

    except (SyntaxError, IOError):
        print "failed"

    else:
        print "OK"