Merge pull request #3114 from tianyu139/hotfix

Fixed bug in ImageDraw.multiline_textsize()
This commit is contained in:
Hugo 2018-07-01 21:34:45 +03:00 committed by GitHub
commit abae745da1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -231,6 +231,11 @@ class TestImageFont(PillowTestCase):
self.assertEqual(draw.textsize(TEST_TEXT, font=ttf),
draw.multiline_textsize(TEST_TEXT, font=ttf))
# Test that multiline_textsize corresponds to ImageFont.textsize()
# for single line text
self.assertEqual(ttf.getsize('A'),
draw.multiline_textsize('A', font=ttf))
# Test that textsize() can pass on additional arguments
# to multiline_textsize()
draw.textsize(TEST_TEXT, font=ttf, spacing=4)

View File

@ -271,7 +271,7 @@ class ImageDraw(object):
line_width, line_height = self.textsize(line, font, spacing,
direction, features)
max_width = max(max_width, line_width)
return max_width, len(lines)*line_spacing
return max_width, len(lines)*line_spacing - spacing
def Draw(im, mode=None):