[SDL] crashing SDL_ttf bug

Pete Shinners shredwheat at mediaone.net
Fri Mar 16 07:33:07 PST 2001


one of my pygame users has dug up a rare crashing bug in SDL_ttf.
his solution here is to simply add 1 to the width of the rendered
image.


----- Original Message -----
From: "Niki Spahiev" <niki at vintech.bg>
To: <pygame-users at seul.org>
Sent: Friday, March 16, 2001 4:30 AM
Subject: [pygame] SDL_ttf 1.2.2 BUG

> I found one very hard to reproduce bug in SDL_ttf.
> Due to rounding of gliph->bitmap.width sometimes
> gliph->minx + gliph->bitmap.width > gliph->maxx
>
> This leads to no enough width for allocated surface and Seg_faults.
> I fixed it by incrementing 'w' from TTF_SizeUNICODE before
> SDL_AllocSurface e.g.:
>
>         /* Get the dimensions of the text surface */
>         if ( (TTF_SizeUNICODE(font, text, &w, &h) < 0) || !w ) {
>                 TTF_SetError("Text has zero width");
>                 return(NULL);
>         }
>
>         /* Create the target surface, 32-bit ARGB format */
>         width = w;
>         w++;            !!!
>         w = (w+3)&~3;
>         textbuf = SDL_AllocSurface(SDL_SWSURFACE, w, h, 32,
>                                    0x00FF0000, 0x0000FF00, 0x000000FF,
>                                    0xFF000000);
>
> I am not sure that this is enough, but it works for me.
>
> regards,
> Niki Spahiev









More information about the SDL mailing list