Mohan
Mohan

Reputation: 1901

Displaying Text with SDL_ttf without font file hard code

I have code in C LANGUAGE to display text on screen using SDL_ttf library in linux.

TTF_Font *font;
      font = TTF_OpenFont("FreeSans.ttf", 20);

But in this I don't want to give file name as hard coded or file path. so when I execute this programme on other Linux machine it should run fine. I don't want to keep always this font file with my executable.

Is there any way to write portable code for TTF_OpenFont ? or i can use something else that can solve my problem ?

Upvotes: 1

Views: 491

Answers (1)

nim
nim

Reputation: 2441

To avoid hardcoding fonts you need to integrate SDL_TTF with fontconfig.

Or use fontconfig through a higher-level framework like Pango.

Upvotes: 0

Related Questions