blob: 371de1ccc328a348d501b53db643660729a2a8ce [file] [log] [blame]
mblighfd6682452007-09-30 22:02:02 +00001#!/usr/bin/env python
2
3import gd, os, cStringIO, urllib2, sys
4
5fontlist = [
6 '/usr/lib/python2.4/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
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()