TTF_InsertTextString(3)

✨ TTF_InsertTextString(3) ✨

okay bestie, we're in the SDL_ttf3 FUNCTIONS corner of the manual and this one is literally about sliding some text into a text object. no cap. 🫢


πŸ’– NAME πŸ’–

TTF_InsertTextString β€” Insert UTF-8 text into a text object.


πŸ“ HEADER FILE πŸ“

Defined in SDL3_ttf/SDL_ttf.h


🌸 SYNOPSIS 🌸

#include "SDL3_ttf/SDL_ttf.h"

bool TTF_InsertTextString(TTF_Text *text, int offset, const char *string, size_t length);

πŸ¦‹ DESCRIPTION πŸ¦‹

Heads up bestie: this function may cause the internal text representation to be rebuilt. so like, it's doing stuff behind the scenes. she's got main character energy and she's rearranging the furniture. πŸ’…


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • text β€” the TTF_Text you wanna modify. that's your girl, go edit her.
  • offset β€” the offset, in bytes, from the beginning of the string if >= 0, and the offset from the end of the string if < 0. ⚠️ real talk though: this does not do UTF-8 validation, so you should only insert at UTF-8 sequence boundaries. do not just vibe-check your way to a random byte, i'm begging. 😭
  • string β€” the UTF-8 text to insert. the actual content, the moment, the slay.
  • length β€” the length of the text, in bytes, or 0 for null terminated text. yes bestie, 0 means "just read till the null, i trust you". 🌈

⭐ RETURN VALUE ⭐

Returns true on success or false on failure. πŸŽ‰ if it flops, call SDL_GetError() for more information β€” she will tell you exactly what went wrong, she's not shy.


🧡 THREAD SAFETY 🧡

This function should be called on the thread that created the text. periodt. don't be texting her from a different thread, that's not the vibe. πŸ™ˆ


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL_ttf 3.0.0. so it's been iconic for a minute.


🌈 SEE ALSO 🌈


mwah πŸ’‹ that's the whole page. written up in the SDL_ttf manual, version SDL_ttf 3.2.2, under the SDL_ttf name. go insert something gorgeous, bestie β€” you got this fr fr πŸ’œβœ¨

πŸ“¦ where this page comes from