Reputation: 1587
I'm basically having the same "original" problem that this user was having here: C++ SDL segmentation fault .
However, even after installing the font I am trying to use, I still get a Segmentation Fault as soon as I run the program.
I used gdb to debug and it returns with:
TTF_SizeUNICODE (font=font@entry=0x0, text=text@entry=0xbfffefe0, w=w@entry=0xbfffef9c, h=h@entry=0xbfffefa0) at SDL_ttf.c:1127
1127 use_kerning = FT_HAS_KERNING( font->face ) && font->kerning;
Here is how I am loading the TTF font:
TTF_Font *font;
TTF_Init();
font = TTF_OpenFont("/includes/game_over.ttf",30);
Any ideas on what this means?
Upvotes: 1
Views: 1193
Reputation: 1239
Font is null because TTF_OpenFont
wasn't able to open the font. Add this line right after TTF_OpenFont to see what's the problem (e.g. file is missing? insufficent permissions, etc) Or did you mean includes/game_over.ttf instead of /includes/game_over.ttf which points to root folder?
if(!font) {
printf("TTF_OpenFont: %s\n", TTF_GetError());
}
Upvotes: 4