ttfSetFontLanguage function ttf

bool ttfSetFontLanguage(
  1. Pointer<TtfFont> font,
  2. String? languageBcp47
)

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

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

This updates any TTF_Text objects using this font.

\param font the font to specify a language for. \param language_bcp47 a null-terminated string containing the desired language's BCP47 code. Or null to reset the value. \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 font.

\since This function is available since SDL_ttf 3.0.0.

extern SDL_DECLSPEC bool SDLCALL TTF_SetFontLanguage(TTF_Font *font, const char *language_bcp47)

Implementation

bool ttfSetFontLanguage(Pointer<TtfFont> font, String? languageBcp47) {
  final ttfSetFontLanguageLookupFunction = _libTtf
      .lookupFunction<
        Uint8 Function(Pointer<TtfFont> font, Pointer<Utf8> languageBcp47),
        int Function(Pointer<TtfFont> font, Pointer<Utf8> languageBcp47)
      >('TTF_SetFontLanguage');
  final languageBcp47Pointer = languageBcp47 != null
      ? languageBcp47.toNativeUtf8()
      : nullptr;
  final result =
      ttfSetFontLanguageLookupFunction(font, languageBcp47Pointer) == 1;
  calloc.free(languageBcp47Pointer);
  return result;
}