TTF_OpenFont returns NULL

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 " Can't load the font file "

  • .ttf chmod - 777
  • I tried to run the program using root

I'm running out of ideas.

+4
source share
2 answers

Yes, I initialized TTF.

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

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

+5
source

SDL_TTF SDL2 Ubuntu, : sudo apt-get install libsdl2-ttf-dev

0

All Articles