Pillow/Tests/test_font_bdf.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
727 B
Python
Raw Normal View History

from __future__ import annotations
2024-01-20 14:23:03 +03:00
2025-03-01 13:41:30 +03:00
import io
2020-01-27 14:46:52 +03:00
import pytest
from PIL import BdfFontFile, FontFile
filename = "Tests/images/courB08.bdf"
2024-01-22 10:42:43 +03:00
def test_sanity() -> None:
2025-03-01 13:41:30 +03:00
with open(filename, "rb") as fp:
font = BdfFontFile.BdfFontFile(fp)
2014-06-10 13:10:47 +04:00
2020-01-27 14:46:52 +03:00
assert isinstance(font, FontFile.FontFile)
assert len([_f for _f in font.glyph if _f]) == 190
2014-06-10 13:10:47 +04:00
def test_zero_width_chars() -> None:
2025-03-01 13:41:30 +03:00
with open(filename, "rb") as fp:
data = fp.read()
data = data[:2650] + b"\x00\x00" + data[2652:]
BdfFontFile.BdfFontFile(io.BytesIO(data))
2024-01-22 10:42:43 +03:00
def test_invalid_file() -> None:
2020-01-27 14:46:52 +03:00
with open("Tests/images/flower.jpg", "rb") as fp:
with pytest.raises(SyntaxError):
BdfFontFile.BdfFontFile(fp)