@@ -73,6 +73,7 @@ void text_copy_rendered(SFT_Image *dest, const SFT_Image *source, int x0, int y0
7373
7474 for (int y = 0 ; y < source -> height ; y ++ ) {
7575 for (int x = 0 ; x < source -> width ; x ++ ) {
76+ if (s [x ] == 0 ) continue ;
7677 double t = s [x ] * inv255 ;
7778 unsigned short r = (1.0 - t ) * ((d [x ] & 0x7C00 ) >> 10 ) + t * maskr ;
7879 unsigned short g = (1.0 - t ) * ((d [x ] & 0x3E0 ) >> 5 ) + t * maskg ;
@@ -152,7 +153,8 @@ void text_dim_rendered(double *margin, double *height, double *width, const char
152153 * width = MAX (* width , lwidth ) + 2 * * margin ;
153154}
154155
155- hal_bitmap text_create_rendered (const char * font , double size , const char * text , int color )
156+ hal_bitmap text_create_rendered (const char * font , double size , const char * text ,
157+ int color , int outline , double thick )
156158{
157159 text_load_font (& sft , font , size , & lmtx );
158160
@@ -185,6 +187,19 @@ hal_bitmap text_create_rendered(const char *font, double size, const char *text,
185187 text_new_rendered (& image , mtx .minWidth , mtx .minHeight , 0 );
186188 sft_render (& sft , gid , image );
187189 sft_kerning (& sft , ogid , gid , & kerning );
190+
191+ if (thick <= 0 ) goto noOutline ;
192+
193+ for (int dx = - thick ; dx <= thick ; dx ++ ) {
194+ for (int dy = - thick ; dy <= thick ; dy ++ ) {
195+ if (!dx && !dy ) continue ;
196+ text_copy_rendered (& canvas , & image ,
197+ x + mtx .leftSideBearing + dx ,
198+ y + mtx .yOffset + dy , outline );
199+ }
200+ }
201+
202+ noOutline :;
188203 x += kerning .xShift ;
189204 text_copy_rendered (& canvas , & image , x + mtx .leftSideBearing ,
190205 y + mtx .yOffset , color );
0 commit comments