home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pypil112.zip / Scripts / pilfont.py < prev    next >
Text File  |  2001-05-03  |  1KB  |  61 lines

  1. #
  2. # THIS IS WORK IN PROGRESS
  3. #
  4. # The Python Imaging Library
  5. # $Id$
  6. #
  7. # PIL raster font compiler
  8. #
  9. # history:
  10. # 97-08-25 fl   created
  11. #
  12. # Copyright (c) Fredrik Lundh 1997.  All rights reserved.
  13. #
  14. # See the README file for information on usage and redistribution.
  15. #
  16.  
  17. VERSION = "0.3"
  18.  
  19. import glob, os, sys
  20.  
  21. # drivers
  22. import BdfFontFile
  23. import PcfFontFile
  24.  
  25. print "PILFONT", VERSION, "-- PIL font compiler."
  26. print "Copyright (c) Fredrik Lundh 1997.  All rights reserved."
  27. print
  28.  
  29. if len(sys.argv) <= 1:
  30.     print "Usage: pilfont fontfiles..."
  31.     print
  32.     print "Convert given font files to the PIL raster font format."
  33.     print "This version of pilfont supports X BDF and PCF fonts."
  34.     sys.exit(1)
  35.  
  36. files = []
  37. for f in sys.argv[1:]:
  38.     files = files + glob.glob(f)
  39.  
  40. for f in files:
  41.  
  42.     print f + "...",
  43.  
  44.     try:
  45.  
  46.         fp = open(f, "rb")
  47.  
  48.         try:
  49.             p = PcfFontFile.PcfFontFile(fp)
  50.         except SyntaxError:
  51.             fp.seek(0)
  52.             p = BdfFontFile.BdfFontFile(fp)
  53.  
  54.         p.save(f)
  55.  
  56.     except (SyntaxError, IOError):
  57.         print "failed"
  58.  
  59.     else:
  60.         print "OK"
  61.