TTF_SetFontStyle(3)

πŸ’… TTF_SetFontStyle(3) β€” the SDL_ttf3 glow-up page πŸŽ€

okay so bestie, you found it: TTF_SetFontStyle, one of the SDL_ttf3 FUNCTIONS. It lives in SDL3_ttf/SDL_ttf.h and it's literally the "give my font a whole new personality" button. Let's get into it πŸ¦‹


✨ NAME ✨

TTF_SetFontStyle β€” set a font's current style. that's it, that's the whole vibe. πŸ’–


πŸ“ HEADER FILE πŸ“

Defined in SDL3_ttf/SDL_ttf.h β€” that's the file you gotta have, no cap.


🌸 SYNOPSIS 🌸

#include "SDL3_ttf/SDL_ttf.h"

void TTF_SetFontStyle(TTF_Font *font, TTF_FontStyleFlags style);

two params, one function, zero drama. slay. ✨


πŸ’œ DESCRIPTION πŸ’œ

So here's the tea: this updates any TTF_Text objects using this font, and it clears already-generated glyphs, if any, from the cache. meaning: your text gets a fresh new look, and the old cached glyphs get evicted like they overstayed their welcome. πŸ™ˆ

The font styles are a set of bit flags, OR'd together (so you stack them with |, like accessories β€” the more the better πŸ’…):

  • TTF_STYLE_NORMAL (is zero β€” yes, the "no style" option is literally zero, iconic)
  • TTF_STYLE_BOLD
  • TTF_STYLE_ITALIC
  • TTF_STYLE_UNDERLINE
  • TTF_STYLE_STRIKETHROUGH

🫢 FUNCTION PARAMETERS 🫢

  • font β€” the font to set a new style on. your main character. πŸ‘‘
  • style β€” the new style values to set, OR'd together. mix and match, go feral.

πŸ”₯ THREAD SAFETY πŸ”₯

This function should be called on the thread that created the font. like, don't be calling it from some random other thread, that's not the move. keep it in the family. πŸ’€


⭐ AVAILABILITY ⭐

This function is available since SDL_ttf 3.0.0. so it's been here for a minute, you're not early, you're right on time. πŸŽ€


🌈 SEE ALSO 🌈

go read TTF_GetFontStyle(3) if you wanna check what style a font is currently serving. iykyk. πŸ¦‹


okay bestie that's the whole page, and it was all from SDL_ttf, version 3.2.2 β€” so if it's broken, blame the version, not me. mwah, go style something pretty πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from