mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
issue warning if Raqm layout is requested, but Raqm is not available
This commit is contained in:
parent
f018518e24
commit
a278e0aa65
|
@ -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."
|
||||
)
|
||||
|
|
|
@ -169,6 +169,12 @@ class FreeTypeFont:
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user