[Image-SIG] Truetype representation in Windows and Linux

daniel at roseman.org.uk daniel at roseman.org.uk
Sat Jul 29 21:31:08 CEST 2006

Thanks for the tip. Any clues on how to go about this? I'm actually using the FreeBSD 
ports (I lied about Linux) and I'm not really up to speed with building stuff. What 
would I need to run to fix this?

Sorry about the newbie questions and thanks for any help.

On Sat, 29 Jul 2006 14:54:04 -0400 (EDT), "Adam Twardoch" <adam at twardoch.com> wrote:
> My guess is that on your Windows machine, FreeType (that is used to render
> texts from PIL) is compiled with native TrueType hinting support enabled
> while on Linux, you have FreeType without native TrueType hinting option.
> You'd need to build FreeType with native TrueType hinting enabled to get
> the same results as on Windows.
> A.
>> Hi,
>> I'm using PIL to dynamically create graphical text headers for my
> website,
>> using a truetype font. Testing this at home on my Windows box works
> fine.
>> When I upload it to the Linux server, the fonts appear subtly different
> -
>> the size of the overall image isn't quite right, and the text appears
>> either squashed or spaced wrongly.
>> Here's the relevant code:
>>     imf = ImageFont.truetype(fontfile, int(fontsize))
>>     size = imf.getsize(header)
>>     im = Image.new("RGB", size, "white")
>>     draw = ImageDraw.Draw(im)
>>     draw.text((0, 0), header, font=imf, fill=colour)
>> With fontfile and fontsize set to the relevant values, and using sample
>> text "Randomtext", this produces an image of size 227x44 on Windows and
>> 229x44 on Linux - doesn't sound like much, but the difference is clearly
>> noticeable (and the designer will kill me). Both machines are running
>> Python 2.4.2 and PIL 1.1.5.
>> Any ideas, anyone?
>> --
>> DR.
>> _______________________________________________
>> Image-SIG maillist  -  Image-SIG at python.org
>> http://mail.python.org/mailman/listinfo/image-sig

More information about the Image-SIG mailing list