ALLEGRO_GLYPH(3alleg5)
π ALLEGRO_GLYPH π
okay bestie, so this is the ALLEGRO_GLYPH page from the Allegro 5 API manual, and it's literally the blueprint for how one single character in a font is put together. one glyph. one vibe. let's go π¦
β¨ SYNOPSIS β¨
#include <allegro5/allegro_font.h>
typedef struct ALLEGRO_GLYPH ALLEGRO_GLYPH;
πΈ DESCRIPTION πΈ
it's a struct, bestie, and it holds all the properties of a character in a font. the whole little dossier. the character sheet, if you will π
typedef struct ALLEGRO_GLYPH {
ALLEGRO_BITMAP *bitmap; // the bitmap the character is on
int x; // the x position of the glyph on bitmap
int y; // the y position of the glyph on bitmap
int w; // the width of the glyph in pixels
int h; // the height of the glyph in pixels
int kerning; // pixels of kerning (see below)
int offset_x; // x offset to draw the glyph at
int offset_y; // y offset to draw the glyph at
int advance; // number of pixels to advance after this character
} ALLEGRO_GLYPH;
so bitmap β that's the bitmap the character is living on. and lowkey important: bitmap may be a sub-bitmap in the case of color fonts β¨ and it can also be NULL, in which case you draw nothing, periodt. (that's sometimes just how it is for whitespace characters in TTF fonts, no drama π)
then kerning β bestie, you need to add this to the x position you're drawing to if you want your text actually kerned, and it depends on which codepoints al_get_glyph(3alleg5) was called with. iykyk π
and the way that glyphs are tightly packed onto the bitmap?? yeah. so you have to add offset_x and offset_y to your draw position or your text is gonna look all kinds of wrong. not optional. do it π
finally advance β that's the number of pixels you add to your x position to advance to the next character in a string, and yes it includes kerning. it's giving "the whole package" π
β SINCE β
5.2.1
π«Ά [Unstable API]: this API is new and subject to refinement. so like, it's iconic, but it might still get a lil glow-up. treat it gently bestie π
π₯ SEE ALSO π₯
and that's the whole page, no cap π
the Allegro reference manual said what it said, and ALLEGRO_GLYPH(3alleg5) is out here being the main character of font rendering. go forth and kern responsibly, bestie π¦πΈπ
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms