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

3.4.12 TTF_RenderGlyph_Blended

SDL_Surface *TTF_RenderGlyph_Blended(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. Pixels are blended between transparent and this color to draw the antialiased glyph.

Render the glyph for the UNICODE ch using font with fg color onto a new surface, using the Blended mode (see section Blended). 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 blended 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.4 TTF_RenderGlyph_Solid,
3.4.8 TTF_RenderGlyph_Shaded,
3.4.9 TTF_RenderText_Blended,
3.4.10 TTF_RenderUTF8_Blended,
3.4.12 TTF_RenderGlyph_Blended,
3.3.19 TTF_GlyphMetrics

This document was generated on November, 13 2009 using texi2html