Only check width and height of transposed fonts once

This commit is contained in:
Andrew Murray 2023-04-10 17:34:33 +10:00
parent b27794fc01
commit fa6cd4a195

View File

@ -305,7 +305,7 @@ def test_rotated_transposed_font(font, orientation):
draw.font = transposed_font
bbox_b = draw.textbbox((20, 20), word)
# Check (w,h) of box a is (h,w) of box b
# Check (w, h) of box a is (h, w) of box b
assert (
bbox_a[2] - bbox_a[0],
bbox_a[3] - bbox_a[1],
@ -314,11 +314,8 @@ def test_rotated_transposed_font(font, orientation):
bbox_b[2] - bbox_b[0],
)
# Check bbox b is (20, 20, 20 + h, 20 + w)
assert bbox_b[0] == 20
assert bbox_b[1] == 20
assert bbox_b[2] == 20 + bbox_a[3] - bbox_a[1]
assert bbox_b[3] == 20 + bbox_a[2] - bbox_a[0]
# Check top left co-ordinates are correct
assert bbox_b[:2] == (20, 20)
# text length is undefined for vertical text
with pytest.raises(ValueError):
@ -360,11 +357,8 @@ def test_unrotated_transposed_font(font, orientation):
bbox_b[3] - bbox_b[1],
)
# Check bbox b is (20, 20, 20 + w, 20 + h)
assert bbox_b[0] == 20
assert bbox_b[1] == 20
assert bbox_b[2] == 20 + bbox_a[2] - bbox_a[0]
assert bbox_b[3] == 20 + bbox_a[3] - bbox_a[1]
# Check top left co-ordinates are correct
assert bbox_b[:2] == (20, 20)
assert length_a == length_b