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

3.3.3 TTF_SetFontStyle

void TTF_SetFontStyle(TTF_Font *font, int style)

font
The loaded font to set the style of.
style
The style as a bitmask composed of the following masks:
TTF_STYLE_BOLD
TTF_STYLE_ITALIC
TTF_STYLE_UNDERLINE
TTF_STYLE_STRIKETHROUGH
If no style is desired then use TTF_STYLE_NORMAL, which is the default.

Set the rendering style of the loaded font.

NOTE: Passing a NULL font into this function will cause a segfault.

NOTE: This will flush the internal cache of previously rendered glyphs, even if there is no change in style, so it may be best to check the current style using TTF_GetFontStyle first.

NOTE: I've seen that TTF_STYLE_UNDERLINE does not work when using TTF_RenderGlyph_* functions, and that TTF_STYLE_STRIKETHROUGH looks like underlines on some glyphs when using TTF_RenderGlyph_* functions. However both seem to work correctly when using the other full string TTF_Render* functions. I've sent in a patch to fix this partially, however I do not alter the surface size and glyph metrics, so sometimes the underline or strikethrough may be outside of the generated surface, and thus not visible when blitted to the screen. In this case, you should probably turn off these styles and draw your own strikethroughs and underlines.

 
// set the loaded font's style to bold italics
//TTF_Font *font;
TTF_SetFontStyle(font, TTF_STYLE_BOLD|TTF_STYLE_ITALIC);

// render some text in bold italics...

// set the loaded font's style back to normal
TTF_SetFontStyle(font, TTF_STYLE_NORMAL);

See Also:
3.3.2 TTF_GetFontStyle,
5. Defines



This document was generated on November, 4 2009 using texi2html