Fix bitmap tests to account for different metrics for bitmap and ttf fonts on some platforms

This commit is contained in:
wiredfool 2015-01-07 21:28:49 -08:00
parent 14a9bba962
commit 8cb58bbd72

View File

@ -11,11 +11,14 @@ class TestImageFontBitmap(PillowTestCase):
im_bitmap = Image.new('RGB', size_final, (255, 255, 255))
im_outline = im_bitmap.copy()
draw_bitmap, draw_outline = ImageDraw.Draw(im_bitmap), ImageDraw.Draw(im_outline)
# Don't know why, but bitmap version is always vertical 1 pixel longer than outline one on my PC.
# Revert back to both 0, 0
draw_bitmap.text((0, 0), text, fill=(0, 0, 0), font=font_bitmap)
draw_outline.text((0, 0), text, fill=(0, 0, 0), font=font_outline)
self.assert_image_similar(im_bitmap, im_outline, 0.01)
# Metrics are different on the bitmap and ttf fonts, more so on some platforms
# and versions of freetype than others. Mac has a 1px difference, linux doesn't.
draw_bitmap.text((0, size_final[1] - size_bitmap[1]),
text, fill=(0, 0, 0), font=font_bitmap)
draw_outline.text((0, size_final[1] - size_outline[1]),
text, fill=(0, 0, 0), font=font_outline)
self.assert_image_similar(im_bitmap, im_outline, 20)
if __name__ == '__main__':
unittest.main()