[Image-SIG] Truetype representation in Windows and Linux

Adam Twardoch adam at twardoch.com
Sat Jul 29 20:54:04 CEST 2006

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.


> 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