2023-12-27 04:32:35 +03:00
|
|
|
from __future__ import annotations
|
2024-01-20 14:23:03 +03:00
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
from pathlib import Path
|
|
|
|
|
2023-12-27 04:32:35 +03:00
|
|
|
import pytest
|
|
|
|
|
2025-02-22 00:09:44 +03:00
|
|
|
from PIL import FontFile, Image
|
|
|
|
|
|
|
|
|
|
|
|
def test_compile() -> None:
|
|
|
|
font = FontFile.FontFile()
|
|
|
|
font.glyph[0] = ((0, 0), (0, 0, 0, 0), (0, 0, 0, 1), Image.new("L", (0, 0)))
|
|
|
|
font.compile()
|
|
|
|
assert font.ysize == 1
|
|
|
|
|
|
|
|
font.ysize = 2
|
|
|
|
font.compile()
|
|
|
|
|
|
|
|
# Assert that compiling again did not change anything
|
|
|
|
assert font.ysize == 2
|
2023-12-27 04:32:35 +03:00
|
|
|
|
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
def test_save(tmp_path: Path) -> None:
|
2023-12-27 04:32:35 +03:00
|
|
|
tempname = str(tmp_path / "temp.pil")
|
|
|
|
|
|
|
|
font = FontFile.FontFile()
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
font.save(tempname)
|