ttfxGetTextSubStringForPoint function ttf

TtfxSubString? ttfxGetTextSubStringForPoint(
  1. Pointer<TtfText> text,
  2. int x,
  3. int y
)

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)

See also:

Implementation

TtfxSubString? ttfxGetTextSubStringForPoint(
  Pointer<TtfText> text,
  int x,
  int y,
) => ffi.using((arena) {
  // 構造体のポインターを arena で確保
  final subStringPointer = arena<TtfSubString>();

  final bl = ttfGetTextSubStringForPoint(text, x, y, subStringPointer);

  if (!bl) {
    return null;
  }

  return TtfxSubString.fromPointer(subStringPointer);
});