TTF_GETTEXTSUBSTRINGFORPOINT(3)
β¨ TTF_GetTextSubStringForPoint β¨
okay bestie, welcome to the SDL_ttf corner of the manual β this one lives in the SDL_ttf3 section and it's literally called TTF_GetTextSubStringForPoint. say that five times fast, i dare you π
πΈ NAME πΈ
TTF_GetTextSubStringForPoint β grab the portion of a text string that is closest to a point. that's it, that's the whole job, and she does it flawlessly π«Ά
π HEADER FILE π
Defined in SDL3_ttf/SDL_ttf.h β that's your girl, go include her.
β¨ SYNOPSIS β¨
#include "SDL3_ttf/SDL_ttf.h"
bool TTF_GetTextSubStringForPoint(TTF_Text *text, int x, int y, TTF_SubString *substring);
π DESCRIPTION π
so the way this works is: you hand her a point, and she hands you back the closest substring of text to that point. no cap. that's the vibe check, and the text passes it every time π
π¦ FUNCTION PARAMETERS π¦
textβ theTTF_Textyou wanna query. she's the main character here, everything revolves around her.xβ the x coordinate, measured relative to the left side of the text. heads up: this can be outside the bounds of the text area and she won't even be mad about it.yβ the y coordinate, measured relative to the top side of the text. same deal: may be outside the bounds of the text area, totally fine, no drama.substringβ a pointer that gets filled in with the closest substring of text to the given point. she writes into it for you, iconic behavior fr fr π
π RETURN VALUE π
Returns true on success or false on failure. if it fails, call SDL_GetError() for more info β she'll tell you what went wrong, and honestly? communication queen π
π§ THREAD SAFETY π§
bestie listen. this function should be called on the thread that created the text. do not go rogue and call her from some random thread, that's not the move, that's asking for chaos π
β AVAILABILITY β
This function is available since SDL_ttf 3.0.0. so if you're on anything older, sorry babe, she hasn't been born yet π
k bye ily, go query some substrings πβ¨ππ¦πΈπ π«Ά
this has been your girl from SDL_ttf, version SDL_ttf 3.2.2, signing off β periodt π
π¦ 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