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β theTTF_Textyou'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
- debian trixie: libsdl3-ttf-doc 3.2.2+ds-1 Β· Zlib
- fedora 43: SDL3_ttf-devel 3.2.2-2.fc43 Β· Zlib AND MIT
- fedora 43: SDL3_ttf-devel 3.2.2-2.fc43 Β· Zlib AND MIT
- fedora 44: SDL3_ttf-devel 3.2.2-4.fc44 Β· Zlib AND MIT
- fedora 44: SDL3_ttf-devel 3.2.2-4.fc44 Β· Zlib AND MIT
- ubuntu questing: libsdl3-ttf-doc 3.2.2+ds-1
- ubuntu resolute: libsdl3-ttf-doc 3.2.2+ds-1build1 Β· Zlib
- ubuntu stonking: libsdl3-ttf-doc 3.2.2+ds-2 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms