SDL_ttf accessing fonts on a Mac

Discussion in 'Mac Programming' started by mkawick, Nov 2, 2008.

  1. mkawick macrumors newbie

    Oct 21, 2008
    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:

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

    Thanks ahead.
  2. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
    It looks like TTF_OpenFont wraps TTF_OpenFontIndex, which wraps TTF_OpenFontRW and SDL_RWFromFile. The lowest level seems to be 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:

    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.


Share This Page