blob: cc3c4f6ff4c1c7e5685ede72d83eb2d9efd5c75a [file] [log] [blame]
mblighfd6682452007-09-30 22:02:02 +00001#!/usr/bin/env python
2
3import gd, os, cStringIO, urllib2, sys
4
5fontlist = [
mblighe90176a2010-01-11 19:32:34 +00006 '/usr/lib/python/site-packages/reportlab/fonts/PenguinAttack.ttf'
mblighfd6682452007-09-30 22:02:02 +00007 '/usr/share/fonts/truetype/freefont/FreeSans.ttf',
8 '/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf',
9 ]
10
11fontpath = '.'
12for 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
18os.environ["GDFONTPATH"] = fontpath
19
20try:
21 FONT
22except NameError:
23 print "no fonts found"
24 sys.exit(1)
25
26def 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
41simple()