ttfxGetTextPosition function ttf

SdlxPoint? ttfxGetTextPosition(
  1. Pointer<TtfText> text
)

Get the position of a text object.

\param text the TTF_Text to query. \param x a pointer filled in with the x offset of the upper left corner of this text in pixels, may be NULL. \param y a pointer filled in with the y offset of the upper left corner of this text in pixels, may be NULL. \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.

\sa TTF_SetTextPosition

extern SDL_DECLSPEC bool SDLCALL TTF_GetTextPosition(TTF_Text *text, int *x, int *y)

Implementation

SdlxPoint? ttfxGetTextPosition(Pointer<TtfText> text) {
  SdlxPoint? result;
  final xPointer = ffi.calloc<Int32>();
  final yPointer = ffi.calloc<Int32>();
  final bl = ttfGetTextPosition(text, xPointer, yPointer);
  if (bl) {
    result = SdlxPoint(xPointer.value, yPointer.value);
  }
  xPointer.callocFree();
  yPointer.callocFree();
  return result;
}