SDL_ttf > Functions > Management


TTF_Font *TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index)





Load src, face index, for use as a font, at ptsize size. 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, face 0, at size 16 into font
TTF_Font *font;
font=TTF_OpenFontRW(SDL_RWFromFile("font.ttf"), 1, 16, 0);
if(!font) {
    printf("TTF_OpenFontIndexRW: %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.

See Also

TTF_OpenFontIndex, TTF_OpenFontRW, TTF_CloseFont

SDL_ttf/Functions/Management/TTF_OpenFontIndexRW (last edited 2008-04-17 08:18:32 by localhost)