TTF_GETTEXTSUBSTRINGFORLINE(3)

πŸ’– TTF_GetTextSubStringForLine(3) β€” SDL_ttf3 FUNCTIONS πŸ’–

okay bestie, sit down, hydrate, and let me tell you about TTF_GetTextSubStringForLine β€” it's the function that hands you the substring of a text object that contains the line you asked for. that's it. that's the whole vibe. πŸŽ€


✨ NAME ✨

TTF_GetTextSubStringForLine β€” get the substring of a text object that contains the given line. no cap. πŸ¦‹


πŸ“ HEADER FILE πŸ“

it lives in SDL3_ttf/SDL_ttf.h, queen. defined right there. go get it. πŸ’…


🌸 SYNOPSIS 🌸

#include "SDL3_ttf/SDL_ttf.h"

bool TTF_GetTextSubStringForLine(TTF_Text *text, int line, TTF_SubString *substring);

look at that signature. immaculate. returns a bool, takes a TTF_Text *, an int, and a TTF_SubString *. periodt. ✨


πŸ’œ DESCRIPTION πŸ’œ

so here's the tea. if line is less than 0, this bad boy gives you back a zero length substring sitting at the beginning of the text, with the

TTF_SUBSTRING_TEXT_START

flag set. 🫢

and if line is greater than or equal to text->num_lines, you get a zero length substring at the end of the text instead, with the

TTF_SUBSTRING_TEXT_END

flag set. iconic boundary behaviour honestly. 😭


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • text β€” the TTF_Text you're querying. the main character of this whole operation. πŸ‘‘
  • line β€” a zero-based line index, in the range [0 .. text->num_lines-1]. yes, zero-based. yes, that's the range. memorize it. πŸ“
  • substring β€” a pointer that gets filled in with the substring containing the offset. it's an out-param bestie, it's giving "I'll tell you when I'm done". πŸ’…

⭐ RETURN VALUE ⭐

returns true on success or false on failure. and if it fails?? call SDL_GetError() for more information, obviously. don't just sit there guessing. 😀


🧚 THREAD SAFETY 🧚

this function should be called on the thread that created the text. do NOT go rogue and call it from some random other thread. keep it in the family. πŸ™ˆ


🌈 AVAILABILITY 🌈

this function is available since SDL_ttf 3.0.0. so if you're on something older, sorry babe, it's not there. πŸ’€


and that's the whole page, bestie!! go forth and substring responsibly!! πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

this lil guide came to you courtesy of SDL_ttf 3.2.2, and yes, the page is literally called TTF_GetTextSubStringForLine(3) β€” slay, bye!! πŸ‘‘πŸŒˆβ­

πŸ“¦ where this page comes from