[Tutor] PIL, fonts and making images
Rinzwind
w.damen at gmail.com
Mon Jan 16 16:19:43 CET 2006
I've been using python wih PIL to create some buttons (automatically inside
my program). The following code works and creates a PNG 70x70 with the
letter 'p' inside.
#!/usr/bin/python
import os, sys
import Image, ImageFont, ImageDraw
image = Image.new('RGBA',(70,70),(0,0,0))
ifo = ImageFont.truetype("arial.ttf",24)
#ifo = ImageFont.truetype("MARRFONT.TTF",24)
draw = ImageDraw.Draw(image)
draw.text((0, 0), 'p', font=ifo)
image.save('image.png','PNG')
I save this program inside a temp dir and copied arial.ttf inside this
directory. It works :-)
Want I want though is to do this with MARRFONT.TTF. That is a (free) font
that has chesspieces inside. (can be downloaded here:
http://antraxja-fonts.iweb.pl/pobierz.php?font=3903 )
The font works: inside the download there's a DOC that I can open with
OO.org and that let's me show the chesspieces (after I copied the font to my
fontsdir). If I type a 'p' in arial and then change the font it shows a
Pawn. Cool isn't it? :)
But when I un-comment the line with this font and save it I get a black
square. Can anyone tell me why it doesn't work?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060116/232ff226/attachment.html
More information about the Tutor
mailing list