Crashing SDL_ttf bug

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)
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");

    /* 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,

I am not sure that this is enough, but it works for me.

Niki Spahiev