ttfSetFontScriptName function

int ttfSetFontScriptName(
  1. Pointer<TtfFont> font,
  2. String? script
)

Set script to be used for text shaping by a font.

Any value supplied here will override the global script set with the deprecated TTF_SetScript().

The supplied script value must be a null-terminated string of exactly four characters.

If SDL_ttf was not built with HarfBuzz support, this function returns -1.

\param font the font to specify a direction for. \param script null-terminated string of exactly 4 characters. \returns 0 on success, or -1 on error.

\since This function is available since SDL_ttf 2.20.0.

extern DECLSPEC int SDLCALL TTF_SetFontScriptName(TTF_Font *font, const char *script)

Implementation

int ttfSetFontScriptName(Pointer<TtfFont> font, String? script) {
  final ttfSetFontScriptNameLookupFunction = libSdl2Ttf.lookupFunction<
      Int32 Function(Pointer<TtfFont> font, Pointer<Utf8> script),
      int Function(Pointer<TtfFont> font,
          Pointer<Utf8> script)>('TTF_SetFontScriptName');
  final scriptPointer = script != null ? script.toNativeUtf8() : nullptr;
  final result = ttfSetFontScriptNameLookupFunction(font, scriptPointer);
  calloc.free(scriptPointer);
  return result;
}