Added test for ImageDraw2 textbbox

This commit is contained in:
Andrew Murray 2023-04-10 17:24:16 +10:00
parent adbb04d5dc
commit b27794fc01

View File

@ -2,7 +2,7 @@ import os.path
import pytest
from PIL import Image, ImageDraw, ImageDraw2
from PIL import Image, ImageDraw, ImageDraw2, features
from .helper import (
assert_image_equal,
@ -170,6 +170,21 @@ def test_text():
assert_image_similar_tofile(im, expected, 13)
@skip_unless_feature("freetype2")
def test_textbbox():
# Arrange
im = Image.new("RGB", (W, H))
draw = ImageDraw2.Draw(im)
font = ImageDraw2.Font("white", FONT_PATH)
# Act
bbox = draw.textbbox((0, 0), "ImageDraw2", font)
# Assert
right = 72 if features.check_feature("raqm") else 70
assert bbox == (0, 2, right, 12)
@skip_unless_feature("freetype2")
def test_textsize_empty_string():
# Arrange