TTF_GetGlyphMetrics(3)

πŸ’– TTF_GetGlyphMetrics β€” the tea on glyph metrics, bestie πŸ’–

okay so this is a page from the SDL_ttf3 FUNCTIONS manual, and it's about TTF_GetGlyphMetrics, which is literally the glow-up measurement tool for your fonts. let's get into it πŸŽ€


✨ NAME ✨

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

like. it tells you how big a glyph is. that's it. that's the whole vibe πŸ’…


πŸ“ HEADER FILE πŸ“

Defined in SDL3_ttf/SDL_ttf.h


🌸 SYNOPSIS 🌸

#include "SDL3_ttf/SDL_ttf.h"

bool TTF_GetGlyphMetrics(TTF_Font *font, Uint32 ch, int *minx, int *maxx, int *miny, int *maxy, int *advance);

look at all those pointer args bestie. she's thorough. she's detail-oriented. she's the main character πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so, to actually understand what these metrics mean (because lowkey the min/max coordinate thing is giving geometry class), here's a genuinely useful link:

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

go read it, i'll wait 🫢


πŸ’œ FUNCTION PARAMETERS πŸ’œ

  • font β€” the font to query. the one you're investigating. the suspect πŸ•΅οΈ
  • ch β€” the codepoint to check. which lil character are we measuring today
  • 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. yes bestie, negative. it's allowed to hang outside the box, she's rebellious like that πŸ’€
  • maxx β€” a pointer filled in with the maximum x coordinate of the glyph from the left edge of its bounding box.
  • 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 too. fr fr
  • maxy β€” a pointer filled in with the maximum y coordinate of the glyph from the bottom edge of its bounding box.
  • advance β€” a pointer filled in with the distance to the next glyph from the left edge of this glyph's bounding box. basically how far you scoot over before the next letter shows up. the personal space budget πŸšΆβ™€οΈ

⭐ RETURN VALUE ⭐

Returns true on success or false on failure; call SDL_GetError() for more information.

so like β€” check the return value. and if it's false, go ask SDL_GetError() what happened, because she always knows 😭


🧚 THREAD SAFETY 🧚

This function should be called on the thread that created the font.

no cap: keep it on the same thread that made the font. don't be passing her around between threads, she does NOT do long distance πŸ’€

🌈 AVAILABILITY 🌈

This function is available since SDL_ttf 3.0.0.


and that's the whole page bestie, you ate that πŸ’…βœ¨

signing off from the SDL_ttf manual, version 3.2.2, page TTF_GetGlyphMetrics(3) β€” stay slay, go measure some glyphs, i'm obsessed with you πŸŽ€πŸ’–πŸ¦‹

πŸ“¦ where this page comes from