On Mon, 2005-01-03 at 18:30, Bill Kendrick wrote:
> Tux Paint in CVS (as of Jan 3, 23:30 UTC) is segfaulting on startup,
> right as (or after) it's loading the fonts:

I had this problem until a made a blacklist. Perhaps you
have a font that needs to be on the blacklist. I suspect
that the font library is buggy. Try eliminating groups of
fonts to see if you can identify a troublemaker.

The X11 "Cursor" font is deadly.

Here, use this:

/////////////////////////////////////////////////////////////////
// gcc -O2 -W -Wall -lSDL -lpthread -lSDL_ttf
// ./a.out `find /usr | egrep '[.](ttf|pfa|pfb)$'`

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <ctype.h>

#include <SDL/SDL_ttf.h>

static void hidespace(char *s){
  while(*s){
    if(*s==' ') *s='.';
    s++;
  }
}

static void testfont(char * const filename){
  char *type = strrchr(filename,'.') + 1;

  TTF_Font *font = TTF_OpenFont(filename,100);

  if(!font){
    fprintf(stderr, "FAIL: %s\n", filename);
    return;
  }

  int total_height = TTF_FontHeight(font);
  int ascent = TTF_FontAscent(font);
  int descent = TTF_FontDescent(font);
  int lineskip = TTF_FontLineSkip(font);
  int numfaces = TTF_FontFaces(font);
  int fixed = TTF_FontFaceIsFixedWidth(font);
  char *familyname = TTF_FontFaceFamilyName(font);
  char *stylename = TTF_FontFaceStyleName(font);
  //int minx, maxx, miny, maxy, advance;
  //int rc = TTF_GlyphMetrics(font, (Uint16)'A', &minx, &maxx, &miny, &maxy, 
&advance);

  hidespace(familyname);
  hidespace(stylename);
  hidespace(filename);

  printf("family=\"%s\" type:%s style=\"%s\" %s\n", familyname, type, 
stylename, filename);

  TTF_CloseFont(font);
}

int main(int argc, char *argv[]){
  if(TTF_Init()) return 5;
  while(--argc) testfont(argv[argc]);
  return 0;
}
///////////////////////////////////////////////////////////


_______________________________________________
Tuxpaint-dev mailing list
[email protected]
http://tux4kids.net/mailman/listinfo/tuxpaint-dev

Reply via email to