ttfGetGlyphMetrics function

bool ttfGetGlyphMetrics(
  1. Pointer<TtfFont> font,
  2. int ch,
  3. Pointer<Int32> minx,
  4. Pointer<Int32> maxx,
  5. Pointer<Int32> miny,
  6. Pointer<Int32> maxy,
  7. Pointer<Int32> advance,
)

Query the metrics (dimensions) of a font's glyph for a UNICODE codepoint.

To understand what these metrics mean, here is a useful link:

https://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html

\param font the font to query. \param ch the codepoint to check. \param minx a pointer filled in with the minimum x coordinate of the glyph from the left edge of its bounding box. This value may be negative. \param maxx a pointer filled in with the maximum x coordinate of the glyph from the left edge of its bounding box. \param miny a pointer filled in with the minimum y coordinate of the glyph from the bottom edge of its bounding box. This value may be negative. \param maxy a pointer filled in with the maximum y coordinate of the glyph from the bottom edge of its bounding box. \param advance a pointer filled in with the distance to the next glyph from the left edge of this glyph's bounding box. \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_GetGlyphMetrics(TTF_Font *font, Uint32 ch, int *minx, int *maxx, int *miny, int *maxy, int *advance)

Implementation

bool ttfGetGlyphMetrics(
    Pointer<TtfFont> font,
    int ch,
    Pointer<Int32> minx,
    Pointer<Int32> maxx,
    Pointer<Int32> miny,
    Pointer<Int32> maxy,
    Pointer<Int32> advance) {
  final ttfGetGlyphMetricsLookupFunction = libSdl3Ttf.lookupFunction<
      Uint8 Function(
          Pointer<TtfFont> font,
          Uint32 ch,
          Pointer<Int32> minx,
          Pointer<Int32> maxx,
          Pointer<Int32> miny,
          Pointer<Int32> maxy,
          Pointer<Int32> advance),
      int Function(
          Pointer<TtfFont> font,
          int ch,
          Pointer<Int32> minx,
          Pointer<Int32> maxx,
          Pointer<Int32> miny,
          Pointer<Int32> maxy,
          Pointer<Int32> advance)>('TTF_GetGlyphMetrics');
  return ttfGetGlyphMetricsLookupFunction(
          font, ch, minx, maxx, miny, maxy, advance) ==
      1;
}