TTF_SetTextPosition(3)

✨ TTF_SetTextPosition ✨

okay bestie, welcome to the SDL_ttf3 FUNCTIONS corner of the manual πŸ’– this one's a lil function called TTF_SetTextPosition, and it's literally the thing that tells a text object where to sit. let's get into it 🫢


🌸 NAME 🌸

TTF_SetTextPosition β€” set the position of a text object. that's it, that's the whole vibe πŸ’…


πŸŽ€ HEADER FILE πŸŽ€

it lives in SDL3_ttf/SDL_ttf.h, no cap πŸ“


πŸ¦‹ SYNOPSIS πŸ¦‹

#include "SDL3_ttf/SDL_ttf.h"

bool TTF_SetTextPosition(TTF_Text *text, int x, int y);

look at her. three little args, returns a bool. iconic. πŸ‘‘


πŸ’œ DESCRIPTION πŸ’œ

so what does she actually do? this one lets you position multiple text objects within a single wrapping text area. like, you've got one big wrapping zone and a bunch of text objects hanging out inside it, and this is how you tell each one where to go. slay ✨

heads up though β€” this function may cause the internal text representation to be rebuilt. so it's not just a free little nudge, okay? she might do some internal rearranging. lowkey important to know πŸ™ˆ


🌈 FUNCTION PARAMETERS 🌈

  • text β€” the TTF_Text to modify. this is your main character, the text object getting moved πŸŽ€
  • x β€” the x offset of the upper left corner of this text, in pixels. that's the horizontal spot πŸ“
  • y β€” the y offset of the upper left corner of this text, in pixels. and that's the vertical one πŸ“

so it's the upper left corner we're positioning, in pixels, both axes. got it? got it. πŸ’–


🧚 THREAD SAFETY 🧚

real talk bestie: this function should be called on the thread that created the text. like, the same thread. don't be out here calling it from some random other thread, that's not the move 😭 keep it in the family fr fr.

⭐ AVAILABILITY ⭐

this function has been available since SDL_ttf 3.0.0 β€” so she's been around, she's not new, she's established. periodt. πŸ‘‘


πŸ’€ SEE ALSO πŸ’€

(yes, go read TTF_GetTextPosition(3) too, she's the one who tells you where things are β€” complementary queen energy πŸ’…)


and that's the whole page, bestie!! 🌸 this was pulled straight from SDL_ttf 3.2.2 in the SDL_ttf manual β€” go forth and position your text objects with confidence, you've got this πŸ«Άβœ¨πŸ’–

πŸ“¦ where this page comes from