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 todayminxβ 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 frmaxyβ 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
- debian trixie: libsdl3-ttf-doc 3.2.2+ds-1 Β· Zlib
- fedora 43: SDL3_ttf-devel 3.2.2-2.fc43 Β· Zlib AND MIT
- fedora 43: SDL3_ttf-devel 3.2.2-2.fc43 Β· Zlib AND MIT
- fedora 44: SDL3_ttf-devel 3.2.2-4.fc44 Β· Zlib AND MIT
- fedora 44: SDL3_ttf-devel 3.2.2-4.fc44 Β· Zlib AND MIT
- ubuntu questing: libsdl3-ttf-doc 3.2.2+ds-1
- ubuntu resolute: libsdl3-ttf-doc 3.2.2+ds-1build1 Β· Zlib
- ubuntu stonking: libsdl3-ttf-doc 3.2.2+ds-2 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms