Generating images with text in them
phil hunt
zen19725 at zen.co.uk
Thu Jul 21 13:13:59 EDT 2005
On Thu, 21 Jul 2005 11:23:46 +0100, Daren Russell <darenr at end-design.co.uk> wrote:
>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)
Thanks! it's working now!
--
Email: zen19725 at zen dot co dot uk
More information about the Python-list
mailing list