Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mkawick

macrumors newbie
Original poster
Oct 21, 2008
6
0
Vancouver, BC
Calling the following TTF_OpenFont function, after installing the SDL_ttf of course, always fails.

int IsEverythingOK = TTF_Init();
if (IsEverythingOK != -1)
{
font=TTF_OpenFont ("Arial.ttf", 10);// fails here
}

This is a common font and everyone should have it installed. I have also tried the following path:
"library/fonts/Arial.ttf"

Does anyone know why? The error code is "Couldn't open Arial.ttf".

Thanks ahead.
 
It looks like TTF_OpenFont wraps TTF_OpenFontIndex, which wraps TTF_OpenFontRW and SDL_RWFromFile. The lowest level seems to be SDL_RWFromFile:
http://sdl.beuc.net/sdl.wiki/SDL_RWFromFile

It looks like you need to pass a const char * with the filename, and a const char * with options. This seems to just be a wrapper for fopen:
http://www.manpagez.com/man/3/fopen/

I would play with opening the file with fopen first and make sure that's working, then when you've got the arguments right to open the font with that, move up and make sure this still works with SDL_RWFromFile. If so, the rest of the levels don't seem to introduce much, so you should be able to jump back up to TTF_OpenFont.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.