SDL School

API reference / Text with SDL_ttf

TTF_Init

Function, SDL_ttf

Starts SDL_ttf. Call it before any other SDL_ttf function.

Declaration

#include <SDL3_ttf/SDL_ttf.h>

bool TTF_Init(void);

Return value

True on success. On failure it returns false, and SDL_GetError gives the reason.

Example

Draw text
if (!TTF_Init()) {
    SDL_Log("TTF_Init failed: %s", SDL_GetError());
    return SDL_APP_FAILURE;
}

See this code run in Draw text. Download the full program (.zip)

In SDL2

The name is the same, but it returns 0 on success.

See also