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

3.4.8 TTF_RenderGlyph_Shaded

SDL_Surface *TTF_RenderGlyph_Shaded(TTF_Font *font, Uint16 ch, SDL_Color fg, SDL_Color bg)

font
Font to render the glyph with. A NULL pointer is not checked.
text
The UNICODE character to render.
fg
The color to render the glyph in. This becomes colormap index 1.
bg
The color to render the background box in. This becomes colormap index 0.

Render the glyph for the UNICODE ch 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.

Returns: a pointer to a new SDL_Surface. NULL is returned on errors, such as when the glyph not available in the font.

 
// Render and cache all printable ASCII characters in shaded black on white
//SDL_Surface *screen;
SDL_Color color={0,0,0}, bgcolor={0xff,0xff,0xff};
SDL_Surface *glyph_cache[128-20];
Uint16 ch;
for(ch=20; ch<128; ++ch)
    glyph_cache[ch-20]=TTF_RenderGlyph_Shaded(font,ch,color,bgcolor);
Combined with a cache of the glyph metrics (minx, miny, and advance), you might make a fast text rendering routine that prints directly to the screen, but with inaccurate kerning. (see section Kerning)

See Also:
3.4.4 TTF_RenderGlyph_Solid,
3.4.12 TTF_RenderGlyph_Blended,
3.4.5 TTF_RenderText_Shaded,
3.4.6 TTF_RenderUTF8_Shaded,
3.4.8 TTF_RenderGlyph_Shaded,
3.3.19 TTF_GlyphMetrics



This document was generated on November, 13 2009 using texi2html