From 8cb58bbd727e50e29d83824f47fe7c7ccb17ddcc Mon Sep 17 00:00:00 2001 From: wiredfool Date: Wed, 7 Jan 2015 21:28:49 -0800 Subject: [PATCH] Fix bitmap tests to account for different metrics for bitmap and ttf fonts on some platforms --- Tests/test_imagefont_bitmap.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Tests/test_imagefont_bitmap.py b/Tests/test_imagefont_bitmap.py index 90b97afd4..9da3d1776 100644 --- a/Tests/test_imagefont_bitmap.py +++ b/Tests/test_imagefont_bitmap.py @@ -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()