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)

See also:

Implementation

SdlxPoint? ttfxGetTextSize(Pointer<TtfText> text) => ffi.using((arena) {
  final wPointer = arena<Int32>();
  final hPointer = arena<Int32>();
  final success = ttfGetTextSize(text, wPointer, hPointer);

  if (!success) {
    return null;
  }

  return SdlxPoint(wPointer.value, hPointer.value);
});