FontError ¶
FontError(message: str, *, path: str)
Bases: ggrust.errors.GgrustError, builtins.ValueError
Raised when a font cannot be registered or embedded.
The file is not a TrueType or OpenType font, has no family name (pass
family=), or its license forbids embedding it in a PDF.
Parameters:
-
message(str) –The full message.
-
path(str) –The font file, or the family name when embedding fails.
Examples:
>>> import tempfile
>>> from pathlib import Path
>>> from ggrust import register_font
>>> from ggrust.errors import FontError
>>> notes = Path(tempfile.mkdtemp()) / "notes.ttf"
>>> _ = notes.write_text("not a font")
>>> try:
... register_font(notes)
... except FontError:
... print("not a font file")
not a font file