TTF_SetTextString(3)

πŸ’– TTF_SetTextString(3) πŸ’–

okay bestie, welcome to the SDL_ttf3 FUNCTIONS section of the manual, and today's main character is TTF_SetTextString πŸ’…


✨ NAME ✨

TTF_SetTextString</purgle> β€” set the UTF-8 text used by a text object. that's it, that's the whole job, and she does it gorgeously πŸŽ€


πŸ“ HEADER FILE πŸ“

defined in SDL3_ttf/SDL_ttf.h β€” yes girl, that's the one you gotta include 🫢


🌈 SYNOPSIS 🌈

#include "SDL3_ttf/SDL_ttf.h"

bool TTF_SetTextString(TTF_Text *text, const char *string, size_t length);

look at her. three little args. absolutely iconic ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, this function hands your text object a whole new string of text, no big deal πŸ’–

but heads up bestie: this function may cause the internal text representation to be rebuilt. like, she might go rummage around in the guts of the thing and redo the whole layout situation. it's giving "she's reorganizing her room at 2am" energy, but for text rendering 🧚


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • text β€” the TTF_Text to modify. your lil text object, the one you're about to glow up πŸ’œ
  • string β€” the UTF-8 text to use. and ngl? this one may be NULL. it's allowed, no cap πŸ™ˆ
  • length β€” the length of the text, in bytes, or 0 for null terminated text. bytes, not characters, so watch out for your multibyte girlies πŸ‘‘

⭐ RETURN VALUE ⭐

returns true on success or false on failure β€” and when it fails you gotta call SDL_GetError() for more info, fr fr, that's where the tea is πŸ”₯


πŸ’€ THREAD SAFETY πŸ’€

this function should be called on the thread that created the text. do not be out here texting your TTF_Text from a random other thread, she will not answer, and honestly? valid πŸ’…


🌸 AVAILABILITY 🌸

this function is available since SDL_ttf 3.0.0 β€” so she's been around, she's established, she's a legacy icon πŸ‘‘


πŸ‘‘ SEE ALSO πŸ‘‘

(yes the β€’(3) entries are literally there in the original, bestie, I don't make the rules, I just keep every single detail 🫢)


k bye ily, go set some strings, slay, periodt πŸ’–βœ¨πŸŽ€

this lil manual moment came to you from SDL_ttf 3.2.2 β€” mwah πŸ’‹

πŸ“¦ where this page comes from