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

3.4.6 TTF_RenderUTF8_Shaded

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

Font to render the text with. A NULL pointer is not checked.
The UTF8 null terminated string to render.
The color to render the text in. This becomes colormap index 1.
The color to render the background box in. This becomes colormap index 0.

Render the UTF8 encoded text using font with fg color onto a new surface filled with the bg color, using the Shaded mode (see section Shaded). 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.

Note that this example uses the same text as in the LATIN1 example, that is because plain ASCII is UTF8 compatible.
// Render some UTF8 text in shaded black on white 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}, bgcolor={0xff,0xff,0xff};
SDL_Surface *text_surface;
if(!(text_surface=TTF_RenderUTF8_Shaded(font,"Hello World!",color,bgcolor))) {
    //handle error here, perhaps print TTF_GetError at least
} else {
    //perhaps we can reuse it, but I assume not for simplicity.

See Also:
3.3.21 TTF_SizeUTF8,
3.4.5 TTF_RenderText_Shaded,
3.4.7 TTF_RenderUNICODE_Shaded,
3.4.8 TTF_RenderGlyph_Shaded,
3.4.2 TTF_RenderUTF8_Solid,
3.4.10 TTF_RenderUTF8_Blended

This document was generated on November, 13 2009 using texi2html