ttfSetFontSdf function ttf

bool ttfSetFontSdf(
  1. Pointer<TtfFont> font,
  2. bool enabled
)

Enable Signed Distance Field rendering for a font.

SDF is a technique that helps fonts look sharp even when scaling and rotating, and requires special shader support for display.

This works with Blended APIs, and generates the raw signed distance values in the alpha channel of the resulting texture.

This updates any TTF_Text objects using this font, and clears already-generated glyphs, if any, from the cache.

\param font the font to set SDF support on. \param enabled true to enable SDF, false to disable. \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.

\sa TTF_GetFontSDF

extern SDL_DECLSPEC bool SDLCALL TTF_SetFontSDF(TTF_Font *font, bool enabled)

Implementation

bool ttfSetFontSdf(Pointer<TtfFont> font, bool enabled) {
  final ttfSetFontSdfLookupFunction = _libTtf
      .lookupFunction<
        Uint8 Function(Pointer<TtfFont> font, Uint8 enabled),
        int Function(Pointer<TtfFont> font, int enabled)
      >('TTF_SetFontSDF');
  return ttfSetFontSdfLookupFunction(font, enabled ? 1 : 0) == 1;
}