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 β€” the TTF_Text you 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