ttfxGetTextSize function ttf

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

Get the size of a text object.

The size of the text may change when the font or font style and size change.

\param text the TTF_Text to query. \param w a pointer filled in with the width of the text, in pixels, may be NULL. \param h a pointer filled in with the height of the 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.

extern SDL_DECLSPEC bool SDLCALL TTF_GetTextSize(TTF_Text *text, int *w, int *h)

Implementation

SdlxPoint? ttfxGetTextSize(Pointer<TtfText> text) {
  SdlxPoint? result;
  final wPointer = ffi.calloc<Int32>();
  final hPointer = ffi.calloc<Int32>();
  final bl = ttfGetTextSize(text, wPointer, hPointer);
  if (bl) {
    result = SdlxPoint(wPointer.value, hPointer.value);
  }
  wPointer.callocFree();
  hPointer.callocFree();
  return result;
}