PIL question. having exactly same font on multiple platforms
t at jollybox.de
Thu Aug 4 12:32:00 CEST 2011
On 04/08/11 12:04, Gelonida N wrote:
> I posted already a question, but perhaps the subject line wasn't clear.
> Subject line was "Text to image with same results on any platform"
Oh, your original message was perfectly clear, and if I knew the answer,
I might have responded. Anyway, into thought.
>>From within a django application
> I'd like create a small image file (e.g. .png)
> which just contains some text.
> I wondered what library would be appropriate and would yield the same
> result independent of the OS (assuming the versions of the python
> libraries are the same)
> Images should be pixel identical independent on the platform on which
> the image is created.
> I made some attempts with PIL (Image / ImageFont / ImageDraw),
> but have difficulties getting the same font under Linux and windows.
Perhaps PIL uses a different font rendering library on each platform?
You could try to get around this by using
http://code.google.com/p/freetype-py/ directly. It's also possible that
different hinting settings on the different systems are playing a role
somehow, somewhere. Perhaps you can tell freetype precisely what to do,
I'm not sure.
If you want exactly the same bitmap on different platforms, you could
just scrap truetype alltogether, and use bitmaps directly, individually
taking the characters you need from a resource file. (you know, one
bitmap with all the characters at known coordinates - or a load of small
Why do you need the images to be identical to the pixel anyway? Surely,
if it's about comparing the text, you would just compare the strings?
And if it's only for displaying the text, then why bother with details
like that as long as it looks good?
More information about the Python-list