@@ -829,34 +829,91 @@ font_getter_style_name(PyObject *self, void *closure)
829829 return PyUnicode_FromString (font_style_name ? font_style_name : "" );
830830}
831831
832+ static PyObject *
833+ font_getter_outline_size (PyFontObject * self , void * closure )
834+ {
835+ if (!PgFont_GenerationCheck (self ))
836+ return RAISE_FONT_QUIT_ERROR ();
837+
838+ #if SDL_TTF_VERSION_ATLEAST (2 , 0 , 12 )
839+ return PyLong_FromLong (self -> outline_size );
840+ #else
841+ return RAISE (pgExc_SDLError ,
842+ "Incorrect SDL_TTF version (requires 2.0.12)" );
843+ #endif
844+ }
845+
832846static int
833- font_setter_outline ( PyObject * self , PyObject * value , void * closure )
847+ font_setter_outline_size ( PyFontObject * self , PyObject * value , void * closure )
834848{
835849 if (!PgFont_GenerationCheck (self )) {
836850 RAISE_FONT_QUIT_ERROR_RETURN (-1 );
837851 }
838852
839- TTF_Font * font = PyFont_AsFont ( self );
840- int val ;
853+ #if SDL_TTF_VERSION_ATLEAST ( 2 , 0 , 12 )
854+ int val = PyLong_AsLong ( value ) ;
841855
842- DEL_ATTR_NOT_SUPPORTED_CHECK ("outline" , value );
856+ if (PyErr_Occurred () && val == -1 )
857+ return -1 ;
843858
844- val = PyLong_AsLong (value );
845- if ((val == -1 ) && (PyErr_Occurred () != NULL ))
859+ if (val < 0 ) {
860+ PyErr_SetString (PyExc_ValueError ,
861+ "outline_size cannot be less than 0" );
846862 return -1 ;
863+ }
864+
865+ self -> outline_size = val ;
847866
848- TTF_SetFontOutline (font , val );
849867 return 0 ;
868+ #else
869+ PyErr_SetString (pgExc_SDLError ,
870+ "Incorrect SDL_TTF version (requires 2.0.12)" );
871+ return -1 ;
872+ #endif
850873}
851874
852875static PyObject *
853- font_getter_outline ( PyObject * self , void * closure )
876+ font_getter_outline_color ( PyFontObject * self , void * closure )
854877{
855- if (!PgFont_GenerationCheck (self )) {
878+ if (!PgFont_GenerationCheck (self ))
856879 return RAISE_FONT_QUIT_ERROR ();
880+
881+ #if SDL_TTF_VERSION_ATLEAST (2 , 0 , 12 )
882+ return Py_BuildValue ("(bbbb)" , self -> outline_color .r ,
883+ self -> outline_color .g , self -> outline_color .b ,
884+ self -> outline_color .a );
885+ #else
886+ return RAISE (pgExc_SDLError ,
887+ "Incorrect SDL_TTF version (requires 2.0.12)" );
888+ #endif
889+ }
890+
891+ static int
892+ font_setter_outline_color (PyFontObject * self , PyObject * value , void * closure )
893+ {
894+ Uint8 rgba [] = {0 , 0 , 0 , 0 };
895+
896+ if (!PgFont_GenerationCheck (self )) {
897+ RAISE_FONT_QUIT_ERROR_RETURN (-1 );
857898 }
858899
859- return PyLong_FromLong (TTF_GetFontOutline (PyFont_AsFont (self )));
900+ #if SDL_TTF_VERSION_ATLEAST (2 , 0 , 12 )
901+ if (!pg_RGBAFromObjEx (value , rgba , PG_COLOR_HANDLE_ALL )) {
902+ return -1 ;
903+ }
904+
905+ if (PyErr_Occurred ())
906+ return -1 ;
907+
908+ SDL_Color val = {rgba [0 ], rgba [1 ], rgba [2 ], SDL_ALPHA_OPAQUE };
909+ self -> outline_color = val ;
910+
911+ return 0 ;
912+ #else
913+ PyErr_SetString (pgExc_SDLError ,
914+ "Incorrect SDL_TTF version (requires 2.0.12)" );
915+ return -1 ;
916+ #endif
860917}
861918
862919static PyObject *
@@ -1088,8 +1145,10 @@ static PyGetSetDef font_getsets[] = {
10881145 DOC_FONT_FONT_ALIGN , NULL },
10891146 {"point_size" , (getter )font_getter_point_size ,
10901147 (setter )font_setter_point_size , DOC_FONT_FONT_POINTSIZE , NULL },
1091- {"outline" , (getter )font_getter_outline , (setter )font_setter_outline ,
1092- DOC_FONT_FONT_OUTLINE , NULL },
1148+ {"outline_color" , (getter )font_getter_outline_color ,
1149+ (setter )font_setter_outline_color , DOC_FONT_FONT_OUTLINECOLOR , NULL },
1150+ {"outline_size" , (getter )font_getter_outline_size ,
1151+ (setter )font_setter_outline_size , DOC_FONT_FONT_OUTLINESIZE , NULL },
10931152 {NULL , NULL , NULL , NULL , NULL }};
10941153
10951154static PyMethodDef font_methods [] = {
0 commit comments