From a871ecb3c585d9ef7025da52074ae55bc346a00d Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 20 Nov 2014 12:50:33 +0000 Subject: [PATCH] also fix return value of drawText --- ox/image.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ox/image.py b/ox/image.py index 5d609d0..e7c7541 100644 --- a/ox/image.py +++ b/ox/image.py @@ -25,7 +25,13 @@ def drawText(image, position, text, font_file, font_size, color): draw = ImageDraw.Draw(image) font = ImageFont.truetype(font_file, font_size, encoding='unic') draw.text(position, text, fill=color, font=font) - return draw.textsize(text, font=font) + size = draw.textsize(text, font=font) + version = getattr(Image, 'PILLOW_VERSION', None) + if version and version > '2.1.0' and version < '2.6.1': + offset = font.getoffset(text) + else: + offset = (0, 0) + return (size[0] + offset[0], size[1] + offset[1]) def getHSL(rgb): rgb = [x / 255 for x in rgb]