ttfxGetTextSubStringForPoint function ttf
Get the portion of a text string that is closest to a point.
This will return the closest substring of text to the given point.
\param text the TTF_Text to query. \param x the x coordinate relative to the left side of the text, may be outside the bounds of the text area. \param y the y coordinate relative to the top side of the text, may be outside the bounds of the text area. \param substring a pointer filled in with the closest substring of text to the given point. \returns true on success or false on failure; call SDL_GetError() for more information.
\threadsafety This function should be called on the thread that created the text.
\since This function is available since SDL_ttf 3.0.0.
extern SDL_DECLSPEC bool SDLCALL TTF_GetTextSubStringForPoint(TTF_Text *text, int x, int y, TTF_SubString *substring)
Implementation
TtfxSubString? ttfxGetTextSubStringForPoint(
Pointer<TtfText> text,
int x,
int y,
) {
TtfxSubString? result;
final subStringPointer = ffi.calloc<TtfSubString>();
final bl = ttfGetTextSubStringForPoint(text, x, y, subStringPointer);
if (bl) {
result = TtfxSubString()..loadFromPointer(subStringPointer);
}
subStringPointer.callocFree();
return result;
}