API reference / Text with SDL_ttf
TTF_OpenFont
Function, SDL_ttf
Opens a font file at one size. For a second size, open the file again.
Declaration
#include <SDL3_ttf/SDL_ttf.h>
TTF_Font * TTF_OpenFont(const char *file, float ptsize);Parameters
file | The path of the font file. |
ptsize | The size in points. |
Return value
A new font, or NULL on failure.
Example
title_font = TTF_OpenFont(FONT_PATH, 40.0f);See this code run in Draw text. Download the full program (.zip)
In SDL2
The name is the same, but the size is an int.