mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
update test_font_pcf to use getbbox
This commit is contained in:
parent
c854bf8d1c
commit
f34a6460ef
|
@ -68,12 +68,16 @@ def test_textsize(request, tmp_path):
|
||||||
tempname = save_font(request, tmp_path)
|
tempname = save_font(request, tmp_path)
|
||||||
font = ImageFont.load(tempname)
|
font = ImageFont.load(tempname)
|
||||||
for i in range(255):
|
for i in range(255):
|
||||||
(dx, dy) = font.getsize(chr(i))
|
(ox, oy, dx, dy) = font.getbbox(chr(i))
|
||||||
|
assert ox == 0
|
||||||
|
assert oy == 0
|
||||||
assert dy == 20
|
assert dy == 20
|
||||||
assert dx in (0, 10)
|
assert dx in (0, 10)
|
||||||
|
assert font.getlength(chr(i)) == dx
|
||||||
for i in range(len(message)):
|
for i in range(len(message)):
|
||||||
msg = message[: i + 1]
|
msg = message[: i + 1]
|
||||||
assert font.getsize(msg) == (len(msg) * 10, 20)
|
assert font.getlength(msg) == len(msg) * 10
|
||||||
|
assert font.getbbox(msg) == (0, 0, len(msg) * 10, 20)
|
||||||
|
|
||||||
|
|
||||||
def _test_high_characters(request, tmp_path, message):
|
def _test_high_characters(request, tmp_path, message):
|
||||||
|
|
|
@ -101,13 +101,17 @@ def _test_textsize(request, tmp_path, encoding):
|
||||||
tempname = save_font(request, tmp_path, encoding)
|
tempname = save_font(request, tmp_path, encoding)
|
||||||
font = ImageFont.load(tempname)
|
font = ImageFont.load(tempname)
|
||||||
for i in range(255):
|
for i in range(255):
|
||||||
(dx, dy) = font.getsize(bytearray([i]))
|
(ox, oy, dx, dy) = font.getbbox(bytearray([i]))
|
||||||
|
assert ox == 0
|
||||||
|
assert oy == 0
|
||||||
assert dy == 20
|
assert dy == 20
|
||||||
assert dx in (0, 10)
|
assert dx in (0, 10)
|
||||||
|
assert font.getlength(bytearray([i])) == dx
|
||||||
message = charsets[encoding]["message"].encode(encoding)
|
message = charsets[encoding]["message"].encode(encoding)
|
||||||
for i in range(len(message)):
|
for i in range(len(message)):
|
||||||
msg = message[: i + 1]
|
msg = message[: i + 1]
|
||||||
assert font.getsize(msg) == (len(msg) * 10, 20)
|
assert font.getlength(msg) == len(msg) * 10
|
||||||
|
assert font.getbbox(msg) == (0, 0, len(msg) * 10, 20)
|
||||||
|
|
||||||
|
|
||||||
def test_textsize_iso8859_1(request, tmp_path):
|
def test_textsize_iso8859_1(request, tmp_path):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user