Skip to content

Commit cac93c4

Browse files
committed
Raise on invalid string passed to :class:FontDescriptor constructor.
Previously, it silently crashed.
1 parent de034f0 commit cac93c4

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

manimpango/fonts/_font_desc.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ cdef class _FontDescription:
7979
@classmethod
8080
def from_string(cls, string: str):
8181
_t = _FontDescription()
82+
cdef PangoFontDescription* font_desc = NULL
8283
_t.pango_font_desc = \
8384
pango_font_description_from_string(string.encode())
85+
if _t.pango_font_desc is NULL:
86+
raise ValueError("pango_font_description_from_string() returned NULL")
8487
return _t
8588

8689
def __repr__(self):

news/+invalid-font.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Raise on invalid ``string`` passed to :class:`FontDescriptor` constructor.
2+
Previously, it silently crashed.

0 commit comments

Comments
 (0)