[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org