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

3.4.4 TTF_RenderGlyph_Solid

SDL_Surface *TTF_RenderGlyph_Solid(TTF_Font *font, Uint16 ch, SDL_Color fg)

Font to render the glyph with. A NULL pointer is not checked.
The UNICODE character to render.
The color to render the glyph in. This becomes colormap index 1.

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

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 solid black
//SDL_Surface *screen;
SDL_Color color={0,0,0};
SDL_Surface *glyph_cache[128-20];
Uint16 ch;
for(ch=20; ch<128; ++ch)
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.8 TTF_RenderGlyph_Shaded,
3.4.12 TTF_RenderGlyph_Blended,
3.4.1 TTF_RenderText_Solid,
3.4.2 TTF_RenderUTF8_Solid,
3.4.4 TTF_RenderGlyph_Solid,
3.3.19 TTF_GlyphMetrics

This document was generated on November, 13 2009 using texi2html