mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 09:26:16 +03:00
More ImageFont tests
This commit is contained in:
parent
80672b61e8
commit
efa0fa1b4f
|
@ -256,6 +256,34 @@ try:
|
|||
# Check boxes a and b are same size
|
||||
self.assertEqual(box_size_a, box_size_b)
|
||||
|
||||
def test_rotated_transposed_font_get_mask(self):
|
||||
# Arrange
|
||||
text = "mask this"
|
||||
font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||
orientation = Image.ROTATE_90
|
||||
transposed_font = ImageFont.TransposedFont(
|
||||
font, orientation=orientation)
|
||||
|
||||
# Act
|
||||
mask = transposed_font.getmask(text)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(mask.size, (13, 108))
|
||||
|
||||
def test_unrotated_transposed_font_get_mask(self):
|
||||
# Arrange
|
||||
text = "mask this"
|
||||
font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||
orientation = None
|
||||
transposed_font = ImageFont.TransposedFont(
|
||||
font, orientation=orientation)
|
||||
|
||||
# Act
|
||||
mask = transposed_font.getmask(text)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(mask.size, (108, 13))
|
||||
|
||||
def test_free_type_font_get_name(self):
|
||||
# Arrange
|
||||
font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||
|
@ -278,6 +306,28 @@ try:
|
|||
self.assertIsInstance(descent, int)
|
||||
self.assertEqual((ascent, descent), (16, 4)) # too exact check?
|
||||
|
||||
def test_free_type_font_get_offset(self):
|
||||
# Arrange
|
||||
font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||
text = "offset this"
|
||||
|
||||
# Act
|
||||
offset = font.getoffset(text)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(offset, (0, 3))
|
||||
|
||||
def test_free_type_font_get_mask(self):
|
||||
# Arrange
|
||||
font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||
text = "mask this"
|
||||
|
||||
# Act
|
||||
mask = font.getmask(text)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(mask.size, (108, 13))
|
||||
|
||||
def test_load_path_not_found(self):
|
||||
# Arrange
|
||||
filename = "somefilenamethatdoesntexist.ttf"
|
||||
|
|
Loading…
Reference in New Issue
Block a user