-
-
Notifications
You must be signed in to change notification settings - Fork 176
Add Font.set_linesize()
(TTF 2.24.0 feature)
#3282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,6 +226,32 @@ font_get_linesize(PyObject *self, PyObject *_null) | |
#endif | ||
} | ||
|
||
static PyObject * | ||
font_set_linesize(PyObject *self, PyObject *arg) | ||
{ | ||
if (!PgFont_GenerationCheck(self)) { | ||
return RAISE_FONT_QUIT_ERROR(); | ||
} | ||
|
||
#if SDL_TTF_VERSION_ATLEAST(2, 24, 0) | ||
TTF_Font *font = PyFont_AsFont(self); | ||
int linesize = PyLong_AsLong(arg); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried passing a float in and got a deprecation error:
|
||
if (PyErr_Occurred()) | ||
return NULL; | ||
|
||
if (linesize < 0) | ||
return RAISE(PyExc_ValueError, "linesize must be >= 0"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does SDL_ttf do if this isn't true? Also could be good to specify in the docs that this needs to be a positive number including zero. |
||
|
||
TTF_SetFontLineSkip(font, linesize); | ||
|
||
Py_RETURN_NONE; | ||
#else | ||
return RAISE( | ||
PyExc_NotImplementedError, | ||
"TTF_SetFontLineSkip is not available in this version of SDL_ttf"); | ||
#endif | ||
} | ||
|
||
static PyObject * | ||
_font_get_style_flag_as_py_bool(PyObject *self, int flag) | ||
{ | ||
|
@@ -1155,6 +1181,7 @@ static PyMethodDef font_methods[] = { | |
{"get_ascent", font_get_ascent, METH_NOARGS, DOC_FONT_FONT_GETASCENT}, | ||
{"get_linesize", font_get_linesize, METH_NOARGS, | ||
DOC_FONT_FONT_GETLINESIZE}, | ||
{"set_linesize", font_set_linesize, METH_O, DOC_FONT_FONT_SETLINESIZE}, | ||
{"get_bold", font_get_bold, METH_NOARGS, DOC_FONT_FONT_GETBOLD}, | ||
{"set_bold", font_set_bold, METH_O, DOC_FONT_FONT_SETBOLD}, | ||
{"get_italic", font_get_italic, METH_NOARGS, DOC_FONT_FONT_GETITALIC}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a "new in version" entry