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]