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

3.4.1 TTF_RenderText_Solid

SDL_Surface *TTF_RenderText_Solid(TTF_Font *font, const char *text, SDL_Color fg)

font
Font to render the text with. A NULL pointer is not checked.
text
The LATIN1 null terminated string to render.
fg
The color to render the text in. This becomes colormap index 1.

Render the LATIN1 encoded text using font with fg color onto a new surface, using the Solid mode (see section Solid). The caller (you!) is responsible for freeing any returned surface.

NOTE: Passing a NULL font into this function will cause a segfault.
NOTE: Passing a NULL text into this function will result in undefined behavior.

Returns: a pointer to a new SDL_Surface. NULL is returned on errors.

 
// Render some text in solid black to a new surface
// then blit to the upper left of the screen
// then free the text surface
//SDL_Surface *screen;
SDL_Color color={0,0,0};
SDL_Surface *text_surface;
if(!(text_surface=TTF_RenderText_Solid(font,"Hello World!",color))) {
    //handle error here, perhaps print TTF_GetError at least
} else {
    SDL_BlitSurface(text_surface,NULL,screen,NULL);
    //perhaps we can reuse it, but I assume not for simplicity.
    SDL_FreeSurface(text_surface);
}

See Also:
3.3.20 TTF_SizeText,
3.4.2 TTF_RenderUTF8_Solid,
3.4.3 TTF_RenderUNICODE_Solid,
3.4.4 TTF_RenderGlyph_Solid,
3.4.5 TTF_RenderText_Shaded,
3.4.9 TTF_RenderText_Blended



This document was generated on November, 13 2009 using texi2html