ALLEGRO_GLYPH(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’… 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