TTF_CreateText(3)

✨ TTF_CreateText ✨

okay bestie, welcome to the SDL_ttf3 FUNCTIONS corner of the man pages, where we make text objects out of UTF-8 and a text engine. this one's literally the glow-up moment where your string becomes a whole ~object~ πŸ’–

🌸 NAME 🌸

TTF_CreateText β€” Create a text object from UTF-8 text and a text engine.

it's giving "birth of a text object." main character origin story fr fr πŸŽ€


πŸ“ HEADER FILE πŸ“

Defined in SDL3_ttf/SDL_ttf.h

πŸ¦‹ SYNOPSIS πŸ¦‹

#include "SDL3_ttf/SDL_ttf.h"

TTF_Text * TTF_CreateText(TTF_TextEngine *engine, TTF_Font *font, const char *text, size_t length);

πŸ’… FUNCTION PARAMETERS πŸ’…

  • engine β€” the text engine to use when creating the text object, may be NULL. yes bestie, NULL is allowed, she's flexible like that ✨
  • font β€” the font to render with. this is the lewk. the fit. the aesthetic πŸ‘‘
  • text β€” the text to use, in UTF-8 encoding. so like, unicode girlies stay winning 🌈
  • length β€” the length of the text, in bytes, or 0 for null terminated text. bytes, not characters, don't come for me 😭

πŸ”₯ RETURN VALUE πŸ”₯

Returns a TTF_Text object or NULL on failure β€” and if it fails, call SDL_GetError() for more information. so like, if you get NULL back, don't just sit there, go ask SDL_GetError() what happened πŸ’€

ok but real talk, NULL means it did not work, that's the whole vibe check failing. check the error, bestie.

🧚 THREAD SAFETY 🧚

This function should be called on the thread that created the font and text engine. no cap, same thread, that's the rule. don't be chaotic 🫢

⭐ AVAILABILITY ⭐

This function is available since SDL_ttf 3.0.0. so she's been iconic for a while now πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘

like, obviously you're gonna need to clean up after yourself, that's what TTF_DestroyText(3) is for 🌸


k bye ily, this page came from SDL_ttf 3.2.2 β€” mwah, slay, periodt πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from