Skip to content

Commit 0aff9f3

Browse files
committed
Small set_linesize fixes
1 parent dd6854c commit 0aff9f3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

docs/reST/ref/font.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,12 @@ solves no longer exists, it will likely be removed in the future.
514514
.. method:: set_linesize
515515

516516
| :sl:`set the line space of the font text`
517-
| :sg:`set_linesize(linesize) -> int`
517+
| :sg:`set_linesize(linesize) -> None`
518518
519-
Set the height in pixels for a line of text with the font. When rendering
520-
multiple lines of text this refers to the amount of space between lines.
519+
Set the height in pixels for a line of text with the font. When rendering
520+
multiple lines of text this refers to the amount of space between lines.
521+
522+
.. versionadded:: 2.5.4
521523

522524
.. ## Font.set_linesize ##
523525
@@ -534,7 +536,7 @@ solves no longer exists, it will likely be removed in the future.
534536
.. method:: set_point_size
535537

536538
| :sl:`set the point size of the font`
537-
| :sg:`set_point_size(size, /) -> int`
539+
| :sg:`set_point_size(size, /) -> None`
538540
539541
Sets the point size of the font, which is the value that was used to
540542
initialize this font.

src_c/font.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,18 @@ font_set_linesize(PyObject *self, PyObject *arg)
235235

236236
#if SDL_TTF_VERSION_ATLEAST(2, 24, 0)
237237
TTF_Font *font = PyFont_AsFont(self);
238+
239+
if (!PyLong_Check(arg)) {
240+
return RAISE(PyExc_TypeError, "linesize must be an integer");
241+
}
238242
int linesize = PyLong_AsLong(arg);
239-
if (PyErr_Occurred())
243+
if (linesize == -1 && PyErr_Occurred()) {
240244
return NULL;
245+
}
241246

242-
if (linesize < 0)
247+
if (linesize < 0) {
243248
return RAISE(PyExc_ValueError, "linesize must be >= 0");
249+
}
244250

245251
TTF_SetFontLineSkip(font, linesize);
246252

0 commit comments

Comments
 (0)