// g++ ttf.cpp -lSDL2 -lSDL_ttf -L/usr/local/bin
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
using std::cerr;
using std::endl;
int main(int argc, char* args[]){
SDL_Init(SDL_INIT_VIDEO);
TTF_Init();
// Load a font
TTF_Font *font;
font = TTF_OpenFont("fixedsys.ttf", 24);
if(font == NULL){
cerr << "TTF_OpenFont() Failed: " << TTF_GetError() << endl;
TTF_Quit();
SDL_Quit();
return 1;
}
SDL_Surface *text;
SDL_Color text_color = {255, 255, 255};
text = TTF_RenderText_Solid(
font,
"A journey of a thousand miles begins with a single step.",
text_color
);
if(text==NULL){
cerr << "TTF_RenderText_Solid() failed: " << TTF_GetError() << endl;
TTF_Quit();
SDL_Quit();
return 1;
}
SDL_FreeSurface(text);
TTF_Quit();
SDL_Quit();
return 0;
}