Skip to content

Commit

Permalink
Vertical offset error fixed
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
Fridtjof Sterna committed Apr 7, 2014
1 parent c871b81 commit c196372
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion labelprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ def renderImageFromText(self, text, font, fontSize):
fontPath = os.path.join(thisFilePath, 'fonts', font + '.ttf')
imageFont = ImageFont.truetype(fontPath, fontSize, encoding='unic')
(width, height) = imageFont.getsize(text)
(x_offset, y_offset) = imageFont.getoffset(text)
image = Image.new('1', (width, 64), 1)
draw = ImageDraw.Draw(image)
draw.text((0,32-(height/2)), text, font=imageFont)
draw.text((0,32-(height/2) - y_offset), text, font=imageFont)
return image

def initstring(self):
Expand Down

0 comments on commit c196372

Please sign in to comment.