[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.4 TTF_OpenFontIndexRW

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

src
The source SDL_RWops as a pointer. The font is loaded from this.
freesrc
A non-zero value means it will automatically close and free the src for you after it finishes using the src, even if a noncritical error occured.
ptsize
Point size (based on 72DPI) to load font as. This basically translates to pixel height.
index
Choose a font face from a file containing multiple font faces. The first face is always index 0.

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:
3.2.3 TTF_OpenFontIndex, 3.2.2 TTF_OpenFontRW, 3.2.5 TTF_CloseFont



This document was generated on November, 13 2009 using texi2html