ttfCreateText function
Create a text object from UTF-8 text and a text engine.
\param engine the text engine to use when creating the text object, may be NULL. \param font the font to render with. \param text the text to use, in UTF-8 encoding. \param length the length of the text, in bytes, or 0 for null terminated text. \returns a TTF_Text object or NULL on failure; call SDL_GetError() for more information.
\threadsafety This function should be called on the thread that created the font and text engine.
\since This function is available since SDL_ttf 3.0.0.
\sa TTF_DestroyText
extern SDL_DECLSPEC TTF_Text * SDLCALL TTF_CreateText(TTF_TextEngine *engine, TTF_Font *font, const char *text, size_t length)
Implementation
Pointer<TtfText> ttfCreateText(Pointer<TtfTextEngine> engine,
Pointer<TtfFont> font, String? text, int length) {
final ttfCreateTextLookupFunction = libSdl3Ttf.lookupFunction<
Pointer<TtfText> Function(Pointer<TtfTextEngine> engine,
Pointer<TtfFont> font, Pointer<Utf8> text, Uint32 length),
Pointer<TtfText> Function(
Pointer<TtfTextEngine> engine,
Pointer<TtfFont> font,
Pointer<Utf8> text,
int length)>('TTF_CreateText');
final textPointer = text != null ? text.toNativeUtf8() : nullptr;
final result = ttfCreateTextLookupFunction(engine, font, textPointer, length);
calloc.free(textPointer);
return result;
}