Merge pull request #1579 from hugovk/imagefont_getters

Test ImageFont getters
This commit is contained in:
wiredfool 2015-12-14 20:48:03 +00:00
commit 3d5e395bb5

View File

@ -423,6 +423,24 @@ try:
self._test_fake_loading_font(
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.font.glyphs, 4177)
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:
class TestImageFont(PillowTestCase):