Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Tests/test_imagefont.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,3 +1022,16 @@ def test_oom(test_file):
font = ImageFont.truetype(BytesIO(f.read()))
with pytest.raises(Image.DecompressionBombError):
font.getmask("Test Text")


def test_raqm_missing_warning(monkeypatch):
monkeypatch.setattr(ImageFont.core, "HAVE_RAQM", False)
with pytest.warns(UserWarning) as record:
font = ImageFont.truetype(
FONT_PATH, FONT_SIZE, layout_engine=ImageFont.LAYOUT_RAQM
)
assert font.layout_engine == ImageFont.LAYOUT_BASIC
assert str(record[-1].message) == (
"Raqm layout was requested, but Raqm is not available. "
"Falling back to basic layout."
)
6 changes: 6 additions & 0 deletions src/PIL/ImageFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ def __init__(self, font=None, size=10, index=0, encoding="", layout_engine=None)
if core.HAVE_RAQM:
layout_engine = LAYOUT_RAQM
elif layout_engine == LAYOUT_RAQM and not core.HAVE_RAQM:
import warnings

warnings.warn(
"Raqm layout was requested, but Raqm is not available. "
"Falling back to basic layout."
)
layout_engine = LAYOUT_BASIC

self.layout_engine = layout_engine
Expand Down