0

I've been trying to debug this problem and I'm at a loss to what may be causing it. I have two different computers, both are running 64-bit Windows 7 with Python 2.7 installed. I have a script which uses PIL to create a TIFF image and draw lines of text on it. On the first computer, it turns out fine, but on the second computer there's no space in between the lines and they're almost overlapping.

I've checked the versions of Image and TiffImagePlugin and they're the same on both computers. The other modules in PIL also look the same.

Here's the code I'm using to write lines on the image:

def writeLine(img,font,text,y=0,align="LEFT",color=0,indent=40):
  if len(text)==0: text = " "
  draw = ImageDraw.Draw(img)
  if align.upper() == "LEFT": x = indent
  elif align.upper() == "RIGHT": x = img.size[0]-font.getsize(text)[0]-indent
  else:
    a = img.size[0]/2
    b = font.getsize(text)[0]/2
    x = a - b
  draw.text((x,y), text, font=font, fill=color)
  return y+font.getsize(text)[1]

def writeLines(img,font,text,y=0,align="LEFT",color=0,indent=40):
  nextY = y
  if "\n" in text: text = text.splitlines()
  for line in text:
    nextY = writeLine(img,font,line,nextY,align,color,indent)
  return nextY

To make things even stranger, when I view the images in a custom image viewer program written by a vendor, the ones that's having the problems with the line spacing is showing up with a lime green background instead of a white background, although it prints out normally.

Any ideas or thoughts on what could be causing this?

CCKx
  • 1,303
  • 10
  • 22
  • Is `font.getsize(text)` returning the same thing on both systems? – martineau Aug 22 '14 at 20:01
  • They're different. ImageFont.truetype("cour.ttf", 16) is returning a height of 18 on one computer and only 9 on the other. – CCKx Aug 25 '14 at 13:57

0 Answers0