SDL_ttf

SDL_ttf > Functions > Attributes

TTF_SetFontStyle

void TTF_SetFontStyle(TTF_Font *font, int style)

font

style

Set the rendering style of the loaded font.

NOTE: SDL_ttf's "styles" are fake styles generated by artificially skewing or emboldening the regular font. They will not make use of real italic and bold styles, which are considered different fonts - for best results, switch to a real italic or bold font rather than using this functionality.

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 combining TTF_STYLE_UNDERLINE with anything can cause a segfault, other combinations may also do this. Some brave soul may find the cause of this and fix it...

NOTE: Rendered text formatted with TTF_STYLE_BOLD is hollow on the inside (wireframe like) for some reason when you use TTF_RenderSolid. It displayed ok if you use TTF_RenderBlended.

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

// render some text in fake bold italics...

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

See Also

TTF_GetFontStyle, 5. Defines

SDL_ttf_kopie/Functions/Attributes/TTF_SetFontStyle (last edited 2009-02-25 23:12:04 by sign-4d0949c8)