TTF_GetTextSize(3)

✨ TTF_GetTextSize ✨

okay so bestie, welcome to TTF_GetTextSize(3) β€” a lil function from the SDL_ttf3 FUNCTIONS crew, and she's here to tell you exactly how big your text object is. πŸ’–


🌸 NAME 🌸

TTF_GetTextSize β€” get the size of a text object. that's it. that's the whole job. and she ate. πŸ’…


πŸŽ€ HEADER FILE πŸŽ€

defined in SDL3_ttf/SDL_ttf.h


πŸ¦‹ SYNOPSIS πŸ¦‹

#include "SDL3_ttf/SDL_ttf.h"

bool TTF_GetTextSize(TTF_Text *text, int *w, int *h);

πŸ’œ DESCRIPTION πŸ’œ

so like. you ask her how big your text is, and she tells you. simple. iconic. no notes. ✨

but heads up: the size of the text may change when the font or font style and size change. so like, don't go caching that number forever and then acting shocked when it's wrong β€” that's on you, not her. πŸ™ˆ


🫢 FUNCTION PARAMETERS 🫢

  • text β€” the TTF_Text to query. the main character of this whole operation, fr fr. πŸ‘‘
  • w β€” a pointer that gets filled in with the width of the text, in pixels. and guess what? she may be NULL. lowkey flexible of her. πŸ’…
  • h β€” a pointer that gets filled in with the height of the text, in pixels. also may be NULL. the way she lets you opt out of either one… generous. πŸŽ€

πŸ”₯ RETURN VALUE πŸ”₯

returns true on success or false on failure. and if it fails? call SDL_GetError() for more information, bestie. she's not gonna ghost you with a mystery error, go read the message. 😭


🧚 THREAD SAFETY 🧚

⚠️ this function should be called on the thread that created the text.

no cap. do NOT be out here calling her from a random other thread. the text has a home thread and that's where you visit her. periodt. πŸ’€


🌈 AVAILABILITY 🌈

this function is available since SDL_ttf 3.0.0. so if you're on something older… yeah, she doesn't exist yet. sorry babe. πŸ“


and that's the whole page!! go measure some text, you got this. mwah. πŸ’–βœ¨πŸŽ€

β€” xoxo, your fav manual page, brought to you by SDL_ttf 3.2.2, dated SDL_ttf. stay slaying, bestie. πŸ«ΆπŸ’…πŸŒΈ

πŸ“¦ where this page comes from