Test ImageFont getters

This commit is contained in:
hugovk 2015-12-07 20:24:57 +02:00
parent d392b423cd
commit 1ae23a807f

View File

@ -423,6 +423,23 @@ try:
self._test_fake_loading_font( self._test_fake_loading_font(
font_directory+'/Duplicate.ttf', 'Duplicate') font_directory+'/Duplicate.ttf', 'Duplicate')
def test_imagefont_getters(self):
# Arrange
t = ImageFont.truetype(FONT_PATH, FONT_SIZE)
# Act / Assert
self.assertEqual(t.getmetrics(), (16, 4))
self.assertEqual(t.font.ascent, 16)
self.assertEqual(t.font.descent, 4)
self.assertEqual(t.font.height, 20)
self.assertEqual(t.font.x_ppem, 20)
self.assertEqual(t.font.y_ppem, 20)
self.assertEqual(t.getsize('A'), (12, 16))
self.assertEqual(t.getsize('AB'), (24, 16))
self.assertEqual(t.getsize('M'), (12, 16))
self.assertEqual(t.getsize('y'), (12, 20))
self.assertEqual(t.getsize('a'), (12, 16))
except ImportError: except ImportError:
class TestImageFont(PillowTestCase): class TestImageFont(PillowTestCase):