mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-28 02:04:36 +03:00
Merge pull request #6035 from nulano/raqm-warn
This commit is contained in:
commit
8b7c37dc0c
|
@ -1022,3 +1022,16 @@ def test_oom(test_file):
|
||||||
font = ImageFont.truetype(BytesIO(f.read()))
|
font = ImageFont.truetype(BytesIO(f.read()))
|
||||||
with pytest.raises(Image.DecompressionBombError):
|
with pytest.raises(Image.DecompressionBombError):
|
||||||
font.getmask("Test Text")
|
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:
|
if core.HAVE_RAQM:
|
||||||
layout_engine = LAYOUT_RAQM
|
layout_engine = LAYOUT_RAQM
|
||||||
elif layout_engine == LAYOUT_RAQM and not core.HAVE_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
|
layout_engine = LAYOUT_BASIC
|
||||||
|
|
||||||
self.layout_engine = layout_engine
|
self.layout_engine = layout_engine
|
||||||
|
|
Loading…
Reference in New Issue
Block a user