pilfont.py 960B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. VERSION = "0.4"
  12. import site
  13. import glob, os, sys
  14. # drivers
  15. from PIL import BdfFontFile
  16. from PIL import PcfFontFile
  17. if len(sys.argv) <= 1:
  18. print "PILFONT", VERSION, "-- PIL font compiler."
  19. print
  20. print "Usage: pilfont fontfiles..."
  21. print
  22. print "Convert given font files to the PIL raster font format."
  23. print "This version of pilfont supports X BDF and PCF fonts."
  24. sys.exit(1)
  25. files = []
  26. for f in sys.argv[1:]:
  27. files = files + glob.glob(f)
  28. for f in files:
  29. print f + "...",
  30. try:
  31. fp = open(f, "rb")
  32. try:
  33. p = PcfFontFile.PcfFontFile(fp)
  34. except SyntaxError:
  35. fp.seek(0)
  36. p = BdfFontFile.BdfFontFile(fp)
  37. p.save(f)
  38. except (SyntaxError, IOError):
  39. print "failed"
  40. else:
  41. print "OK"