@@ -226,6 +226,38 @@ font_get_linesize(PyObject *self, PyObject *_null)
226226#endif
227227}
228228
229+ static PyObject *
230+ font_set_linesize (PyObject * self , PyObject * arg )
231+ {
232+ if (!PgFont_GenerationCheck (self )) {
233+ return RAISE_FONT_QUIT_ERROR ();
234+ }
235+
236+ #if SDL_TTF_VERSION_ATLEAST (2 , 24 , 0 )
237+ TTF_Font * font = PyFont_AsFont (self );
238+
239+ if (!PyLong_Check (arg )) {
240+ return RAISE (PyExc_TypeError , "linesize must be an integer" );
241+ }
242+ int linesize = PyLong_AsLong (arg );
243+ if (linesize == -1 && PyErr_Occurred ()) {
244+ return NULL ;
245+ }
246+
247+ if (linesize < 0 ) {
248+ return RAISE (PyExc_ValueError , "linesize must be >= 0" );
249+ }
250+
251+ TTF_SetFontLineSkip (font , linesize );
252+
253+ Py_RETURN_NONE ;
254+ #else
255+ return RAISE (
256+ PyExc_NotImplementedError ,
257+ "TTF_SetFontLineSkip is not available in this version of SDL_ttf" );
258+ #endif
259+ }
260+
229261static PyObject *
230262_font_get_style_flag_as_py_bool (PyObject * self , int flag )
231263{
@@ -1148,6 +1180,7 @@ static PyMethodDef font_methods[] = {
11481180 {"get_ascent" , font_get_ascent , METH_NOARGS , DOC_FONT_FONT_GETASCENT },
11491181 {"get_linesize" , font_get_linesize , METH_NOARGS ,
11501182 DOC_FONT_FONT_GETLINESIZE },
1183+ {"set_linesize" , font_set_linesize , METH_O , DOC_FONT_FONT_SETLINESIZE },
11511184 {"get_bold" , font_get_bold , METH_NOARGS , DOC_FONT_FONT_GETBOLD },
11521185 {"set_bold" , font_set_bold , METH_O , DOC_FONT_FONT_SETBOLD },
11531186 {"get_italic" , font_get_italic , METH_NOARGS , DOC_FONT_FONT_GETITALIC },
0 commit comments