TTF_GETPREVIOUSTEXTSUBSTRING(3)

πŸ’– NAME πŸ’–

TTF_GetPreviousTextSubString β€” bestie, this one gets you the previous substring in a text object 🫢

It's from the SDL_ttf3 squad, obviously, and yeah it's a real function, not a vibe. ✨


🌸 HEADER FILE 🌸

It lives in SDL3_ttf/SDL_ttf.h, no cap. That's literally where it's defined, go look. πŸ‘€


✨ SYNOPSIS ✨

#include "SDL3_ttf/SDL_ttf.h"

bool TTF_GetPreviousTextSubString(TTF_Text *text, const TTF_SubString *substring, TTF_SubString *previous);

Okay so it takes three things and gives you back a bool. Simple. Iconic. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So like, you hand it a text object and a substring, and it goes backwards to find the previous one. It's giving "rewind" energy. βͺ

But here's the tea, and it's important: if you call this at the start of the text, it's not gonna error out on you or anything dramatic like that. Instead it returns a zero length substring with the TTF_SUBSTRING_TEXT_START flag set. So like, you always know you've hit the beginning. πŸŽ€


🌈 FUNCTION PARAMETERS 🌈

  • text β€” the TTF_Text you wanna query. That's the text object in question, girl. πŸ’œ
  • substring β€” the TTF_SubString you wanna query. This is your starting point, and we're going back from here. πŸ”₯

⭐ RETURN VALUE ⭐

Returns true on success or false on failure. And if it's a fail? Call SDL_GetError() for more information β€” that's where the actual explanation is hiding, so don't just sit there confused. 😭


🧚 THREAD SAFETY 🧚

Real talk: this function should be called on the thread that created the text. Like, the same one. Don't be out here threading chaos into your life, bestie. πŸ’€

πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL_ttf 3.0.0. So if you're on something older… no it isn't. πŸ™ˆ


That's the whole page, periodt. This little masterpiece came from the SDL_ttf 3.2.2 era, brought to you by the SDL_ttf girlies β€” go get that previous substring, you main character. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from