TTF_OpenFont returning NULL

3.6k Views Asked by At

TTF_OpenFont() returns NULL

I have the same problem, TTF_OpenFont returns NULL and with an error.

    TTF_OpenFont("/absolute/path/to/SourceSansPro-Black.ttf", 25);
    std::cout << TTF_GetError() << std::endl;

And I get the "Couldn't load font file"

  • The .ttf chmod is 777
  • I tried running the program with root

I run out of ideas.

2

There are 2 best solutions below

3
On

Yes, I had initialized TTF.

The problem was that I (don't know how) was using the older SDL_TTF with the SDL 2.0

I downloaded the 2.0 TTF, compiled and linked it and now it works.

0
On

You can install SDL_TTF for SDL2 in Ubuntu using this: sudo apt-get install libsdl2-ttf-dev