TTF_SetTextFont(3)

✨ TTF_SetTextFont ✨

okay so bestie, this one lives in the SDL_ttf3 FUNCTIONS fam β€” it's TTF_SetTextFont(3), and it's literally the glow-up button for your text's font. πŸ’…


🌸 NAME 🌸

TTF_SetTextFont β€” set the font used by a text object. that's it, that's the job, and she does it flawlessly. πŸŽ€


πŸ¦‹ HEADER FILE πŸ¦‹

Defined in SDL3_ttf/SDL_ttf.h


πŸ’– SYNOPSIS πŸ’–

#include "SDL3_ttf/SDL_ttf.h"

bool TTF_SetTextFont(TTF_Text *text, TTF_Font *font);

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea β˜• β€” when a text object already has a font, any changes you make to that font will automatically regenerate the text. like, the text just keeps up with the font's era, no extra steps. iconic behaviour honestly.

but if you set the font to NULL? bestie. the text will continue to render, yes, but changes to the font will no longer affect the text. it's giving "we're not together anymore but i still look cute". πŸ™ˆ

heads up: this function may cause the internal text representation to be rebuilt. so don't be shocked if stuff under the hood gets a little makeover. ✨

🫢 FUNCTION PARAMETERS 🫢

  • text β€” the TTF_Text to modify. the main character in question. πŸ’œ
  • font β€” the font to use, and yes, it may be NULL. no judgement. 🧚

πŸ”₯ RETURN VALUE πŸ”₯

Returns false if the text pointer is null; otherwise, true. and if it goes false on you, go call SDL_GetError() for more information β€” she'll tell you what's up. 😭


πŸ’€ THREAD SAFETY πŸ’€

This function should be called on the thread that created the text. don't be crossing threads, babe, it's not that kind of party. 🚫


⭐ AVAILABILITY ⭐

This function is available since SDL_ttf 3.0.0. so she's been here. she's established. periodt. πŸ‘‘


🌈 SEE ALSO 🌈


and that's the whole vibe check β€” go set some fonts, bestie, you're gonna slay. πŸ¦‹βœ¨

mwah πŸ’– this was page TTF_SetTextFont(3) from the SDL_ttf manual, SDL_ttf 3.2.2 era, brought to you with love and zero cap.

πŸ“¦ where this page comes from