TTF_GetFontFamilyName(3)

πŸ’– TTF_GetFontFamilyName πŸ’–

okay bestie, welcome to the SDL_ttf3 FUNCTIONS section of the manual, we're talking about TTF_GetFontFamilyName(3) today and honestly? it's a lil guy with main character energy πŸŽ€


✨ NAME ✨

TTF_GetFontFamilyName β€” asking a font what its family name is, like a vibe check but for typography 🌸


πŸ“ HEADER FILE πŸ“

it lives in SDL3_ttf/SDL_ttf.h, no cap. that's the whole address, she doesn't have a secret second home πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include "SDL3_ttf/SDL_ttf.h"

const char * TTF_GetFontFamilyName(const TTF_Font *font);

like. that's it. one line. one function. one dream ✨


πŸ’œ DESCRIPTION πŸ’œ

so here's the tea: the string you get back is dictated by the contents of the font file. like, the font file itself decided what it's called, and this function is just the messenger 🫢

⚠️ okay this part MATTERS, listen up: the returned string points to internal storage. do NOT modify it, do NOT free it. it is not yours, it is the font's, and you will simply have to respect that boundary 😭

and it gets even more real β€” that string becomes invalid, along with the rest of the font, the moment font gets handed over to TTF_CloseFont(). so if you were planning to hold onto it after closing the font… babe. no. that's a use-after-free and it's giving undefined behavior πŸ’€ grab what you need before you close her.


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • font β€” the font you're querying. the one you're asking about. the subject of the interrogation, if you will πŸ”

⭐ RETURN VALUE ⭐

it returns the font's family name. that's the whole thing. the family name. iconic behavior honestly πŸ‘‘


🧡 THREAD SAFETY 🧡

it is safe to call this function from any thread. go wild. thread it from wherever. she's chill like that 🌈


πŸ—“οΈ AVAILABILITY πŸ—“οΈ

this function has been available since SDL_ttf 3.0.0, so if you're on anything older, bestie, you're on your own πŸ™ˆ


and that's the whole page!! no SEE ALSO, no warnings beyond the ones we already screamed about, just a cute lil getter doing cute lil getter things πŸ’–

this was TTF_GetFontFamilyName(3) from the SDL_ttf manual, SDL_ttf 3.2.2 era β€” mwah, take care of your strings, don't free what isn't yours, and I'll see you in the next manpage πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from