Pillow/Scripts/pilfont.py

58 lines
1.0 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python
2010-07-31 06:52:47 +04:00
#
# The Python Imaging Library
# $Id$
#
# PIL raster font compiler
#
# history:
# 1997-08-25 fl created
# 2002-03-10 fl use "from PIL import"
#
from __future__ import print_function
2015-04-24 02:41:33 +03:00
import glob
import sys
2010-07-31 06:52:47 +04:00
# drivers
from PIL import BdfFontFile
from PIL import PcfFontFile
2015-08-25 15:27:18 +03:00
VERSION = "0.4"
2010-07-31 06:52:47 +04:00
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.")
2010-07-31 06:52:47 +04:00
sys.exit(1)
files = []
for f in sys.argv[1:]:
files = files + glob.glob(f)
for f in files:
print(f + "...", end=' ')
2010-07-31 06:52:47 +04:00
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")
2010-07-31 06:52:47 +04:00
else:
print("OK")