Generating images with text in them
Daren Russell
darenr at end-design.co.uk
Thu Jul 21 06:23:46 EDT 2005
phil hunt wrote:
> I am trying to generate some images (gifs or pngs) with text in
> them. I can use the Python Imaging Library, but it only has access
> to the default, rather crappy, font.
>
> Ideally I'd like to use one of the nicer fonts that come with my X
> Windows installation. Using Tkinter I can draw these fonts on the
> screen; is there any way to get these fonts into a bitmapped image?
> For example, can I draw some text on a canvas and then "grab" that
> canvas as a bitmap into PIL, and then save it as a file?
>
> Alternately, is there a good source of PIL font files (.pil files)
> somewhere?
>
> If the writers of the Python Imaging Library are reading this, may I
> suggest that they add more fonts to it. Yes, that would increase
> the size, but these days disk space is cheap and programmer time
> expensive.
>
I've just been playing around with this. You can use truetype fonts with:
font = ImageFont.truetype("/path/to/font.ttf", 12)
from version 1.1.4
http://www.pythonware.com/library/pil/handbook/imagefont.htm for more
details
HTH
Daren
More information about the Python-list
mailing list