TTF_GetTextSubString(3)
π TTF_GetTextSubString π
okay bestie, welcome to the SDL_ttf3 FUNCTIONS corner of the manual, this one's literally about grabbing the little slice of a text object that wraps around a text offset π
β¨ NAME β¨
TTF_GetTextSubString β Get the substring of a text object that surrounds a text offset.
πΈ HEADER FILE πΈ
Defined in SDL3_ttf/SDL_ttf.h β that's the one, no cap π«Ά
π¦ SYNOPSIS π¦
#include "SDL3_ttf/SDL_ttf.h"
bool TTF_GetTextSubString(TTF_Text *text, int offset, TTF_SubString *substring);
π DESCRIPTION π
So here's the vibe check π
If offset is less than 0, this will return a zero length substring at the beginning of the text with the TTF_SUBSTRING_TEXT_START flag set.
If offset is greater than or equal to the length of the text string, this will return a zero length substring at the end of the text with the TTF_SUBSTRING_TEXT_END flag set.
like. it never crashes out on you, it just clamps to the edges and flags it. iconic behaviour fr fr β¨
π FUNCTION PARAMETERS π
textβ theTTF_Textto query. the main character of this whole situation πoffsetβ a byte offset into the text string. yes, byte, not character, don't come for me πsubstringβ a pointer filled in with the substring containing the offset. it writes into this, so hand it something real π
β RETURN VALUE β
Returns true on success or false on failure; call SDL_GetError() for more information. no silent L's here, it tells you what went wrong π«Ά
π§ THREAD SAFETY π§
This function should be called on the thread that created the text. like, don't be messy about it, stay on your own thread bestie π
π AVAILABILITY π
This function is available since SDL_ttf 3.0.0 β she's been around, she's established, she's serving longevity π
π quick reminder: theTTF_SUBSTRING_TEXT_STARTandTTF_SUBSTRING_TEXT_ENDflags only show up in those out-of-range cases, and the substring is zero length when they do. that's not a bug, that's the design, periodt.
mwah π this page comes to you courtesy of SDL_ttf 3.2.2 β go off, read the rest of the docs, and stay hydrated π¦β¨
π¦ 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