1

I wrote a script which draws a simple text and saves it using PIL.

import Image, ImageDraw, ImageFont

def get_text(text, size):
  img = Image.new('RGBA', (250, 80))
  font = ImageFont.truetype('HelveticaLTStd-Light.otf', size, encoding='unic')
  draw = ImageDraw.Draw(img)
  draw.text((0, 0), text, fill='#000000', font=font)
  img.save('text.png')

if __name__ == '__main__':
  get_text('test', 64)

When viewing the result on Linux (Ubuntu 11.10) everything is fine with the image:

Linux (Ubuntu 11.10)

But on Windows 7 PIL cuts the text off:

Windows 7

On Linux I simply used apt-get install to install PIL. On Windows I installed PIL using the binaries by Gohlke (http://www.lfd.uci.edu/~gohlke/pythonlibs/). I use Python 2.7 and PIL 1.1.7

Is this problem an OS issue or is there something wrong with my code?

Thank You.

verbit
  • 485
  • 8
  • 16
  • Ok, I see, thank you. So what would you recommend to use for rendering text instead of PIL? (A rather lightweight method if possible.) – verbit Mar 25 '12 at 11:03

0 Answers0