mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Raise ValueError when trying to save without bitmap
This commit is contained in:
parent
85818cd616
commit
6e97dd5cec
12
Tests/test_fontfile.py
Normal file
12
Tests/test_fontfile.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from __future__ import annotations
|
||||
import pytest
|
||||
|
||||
from PIL import FontFile
|
||||
|
||||
|
||||
def test_save(tmp_path):
|
||||
tempname = str(tmp_path / "temp.pil")
|
||||
|
||||
font = FontFile.FontFile()
|
||||
with pytest.raises(ValueError):
|
||||
font.save(tempname)
|
|
@ -118,6 +118,9 @@ class FontFile:
|
|||
self.compile()
|
||||
|
||||
# font data
|
||||
if not self.bitmap:
|
||||
msg = "No bitmap created"
|
||||
raise ValueError(msg)
|
||||
self.bitmap.save(os.path.splitext(filename)[0] + ".pbm", "PNG")
|
||||
|
||||
# font metrics
|
||||
|
|
Loading…
Reference in New Issue
Block a user