-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Changes from 5 commits
8b621db
b26df5d
e84eea5
0467eb6
dd6854c
0aff9f3
ed59a94
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); | ||
aatle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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. 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. When I tried allowing negative sizes, |
||
|
||
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}, | ||
|
Uh oh!
There was an error while loading. Please reload this page.