@@ -683,26 +683,37 @@ font_render(PyObject *self, PyObject *args, PyObject *kwds)
683
683
return NULL ;
684
684
}
685
685
686
+ SDL_Surface * filled_with_outline_surf ;
687
+
686
688
if (outline_size > 0 ) {
687
689
TTF_SetFontOutline (font , outline_size );
688
690
689
691
if (!_create_font_surface (font , text , antialias , outline_color , backg ,
690
692
draw_backg , wraplength , & outline_surf )) {
691
693
return NULL ;
692
694
}
693
- SDL_SetSurfaceBlendMode (outline_surf , SDL_BLENDMODE_BLEND );
694
695
695
696
TTF_SetFontOutline (font , 0 );
696
697
697
- // `surf` and `outline_surf` are **NOT** the same size.
698
- SDL_Rect dstrect ;
699
- dstrect .x = outline_surf -> w / 2 - surf -> w / 2 ;
700
- dstrect .y = outline_surf -> h / 2 - surf -> h / 2 ;
701
- dstrect .w = surf -> w ;
702
- dstrect .h = surf -> h ;
703
- SDL_BlitSurface (surf , NULL , outline_surf , & dstrect );
698
+ filled_with_outline_surf = PG_CreateSurface (
699
+ outline_surf -> w , outline_surf -> h , SDL_PIXELFORMAT_RGBA32 );
704
700
705
- final = (PyObject * )pgSurface_New (outline_surf );
701
+ // `surf` and `outline_surf` are **NOT** the same size.
702
+ SDL_Rect outlinerect ;
703
+ outlinerect .x = filled_with_outline_surf -> w / 2 - outline_surf -> w / 2 ;
704
+ outlinerect .y = filled_with_outline_surf -> h / 2 - outline_surf -> h / 2 ;
705
+ outlinerect .w = outline_surf -> w ;
706
+ outlinerect .h = outline_surf -> h ;
707
+ SDL_Rect fillrect ;
708
+ fillrect .x = filled_with_outline_surf -> w / 2 - surf -> w / 2 ;
709
+ fillrect .y = filled_with_outline_surf -> h / 2 - surf -> h / 2 ;
710
+ fillrect .w = surf -> w ;
711
+ fillrect .h = surf -> h ;
712
+ SDL_BlitSurface (surf , NULL , filled_with_outline_surf , & fillrect );
713
+ SDL_BlitSurface (outline_surf , NULL , filled_with_outline_surf ,
714
+ & outlinerect );
715
+
716
+ final = (PyObject * )pgSurface_New (filled_with_outline_surf );
706
717
}
707
718
else {
708
719
final = (PyObject * )pgSurface_New (surf );
@@ -712,6 +723,9 @@ font_render(PyObject *self, PyObject *args, PyObject *kwds)
712
723
SDL_FreeSurface (surf );
713
724
if (outline_surf != NULL )
714
725
SDL_FreeSurface (outline_surf );
726
+
727
+ if (filled_with_outline_surf != NULL )
728
+ SDL_FreeSurface (filled_with_outline_surf );
715
729
}
716
730
return final ;
717
731
}
0 commit comments