SDL_ttf
SDL_ttf > Functions > Management
TTF_OpenFontRW
TTF_Font *TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize)
src
The source SDL_RWops as a pointer. The font is loaded from this.
freesrc
A non-zero value mean is will automatically close/free the src for you.
ptsize
- Point size (based on 72DPI) to load font as. This basically translates to pixel height.
Load src for use as a font, at ptsize size. This is actually TTF_OpenFontIndexRW(src, freesrc, ptsize, 0). This can load TTF and FON formats. Using SDL_RWops is not covered here, but they enable you to load from almost any source.
NOTE: src is not checked for NULL, so be careful.
Returns: a pointer to the font as a TTF_Font. NULL is returned on errors.
// load font.ttf at size 16 into font
TTF_Font *font;
font=TTF_OpenFontRW(SDL_RWFromFile("font.ttf"), 1, 16);
if(!font) {
printf("TTF_OpenFontRW: %s\n", TTF_GetError());
// handle error
}Note that this is unsafe because we don't check the validity of the SDL_RWFromFile's returned pointer.
