Home | History | Annotate | Download | only in tko
      1 #!/usr/bin/env python
      2 
      3 import gd, os, cStringIO, urllib2, sys
      4 
      5 fontlist = [
      6     '/usr/lib/python/site-packages/reportlab/fonts/PenguinAttack.ttf'
      7     '/usr/share/fonts/truetype/freefont/FreeSans.ttf',
      8     '/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf',
      9     ]
     10 
     11 fontpath = '.'
     12 for f in fontlist:
     13     if os.path.exists(f):
     14         fontpath = fontpath + ':' + os.path.dirname(f)
     15         FONT = os.path.basename(f)
     16         break
     17 
     18 os.environ["GDFONTPATH"] = fontpath
     19 
     20 try:
     21     FONT
     22 except NameError:
     23     print "no fonts found"
     24     sys.exit(1)
     25 
     26 def simple():
     27     im = gd.image((20,200))
     28 
     29     white = im.colorAllocate((255, 255, 255))
     30     black = im.colorAllocate((0, 0, 0))
     31 
     32     #im.colorTransparent(white)
     33     im.interlace(1)
     34 
     35     im.string_ttf(FONT, 10.0, 1.56, (15, 190), sys.argv[1], black)
     36 
     37     f=open(sys.argv[1]+".png","w")
     38     im.writePng(f)
     39     f.close()
     40 
     41 simple()
     42