ALLEGRO_GLYPH(3)
π ALLEGRO_GLYPH(3) π
okay so bestie, welcome to the ALLEGRO_GLYPH(3) page from the Library Functions Manual. It's giving Allegro 5 API, and we're about to get into a struct that describes one character in a font. Cute, small, iconic. π
πΈ NAME πΈ
ALLEGRO_GLYPH β Allegro 5 API
β¨ SYNOPSIS β¨
#include <allegro5/allegro_font.h>
typedef struct ALLEGRO_GLYPH ALLEGRO_GLYPH;
π¦ DESCRIPTION π¦
ALLEGRO_GLYPH is a structure containing the properties of a character in a font. Literally the character lore. It's defined like this:
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;
Now let's break down the fields, because every single one is important:
bitmapβ the bitmap the character is on.xβ the x position of the glyph on bitmap.yβ the y position of the glyph on bitmap.wβ the width of the glyph in pixels.hβ the height of the glyph in pixels.kerningβ pixels of kerning (see below).offset_xβ x offset to draw the glyph at.offset_yβ y offset to draw the glyph at.advanceβ number of pixels to advance after this character.
Okay but the bitmap field has extra tea: it may be a sub-bitmap in the case of color fonts. It can also be NULL, in which case nothing should be drawn β sometimes true for whitespace characters in TTF fonts. So if it's NULL, do not draw, bestie. π
kerning should be added to the x position you draw to if you want your text kerned, and it depends on which codepoints al_get_glyph(3) was called with. This is the "make the letters sit pretty" number, essentially. β¨
Glyphs are tightly packed onto the bitmap, so you need to add offset_x and offset_y to your draw position for the text to look right. Like, don't skip the offsets unless you want your text looking a little chaotic. π
advance is the number of pixels to add to your x position to advance to the next character in a string, and it includes kerning. So it's the "where do I put the next letter" number. Slay. π
π SINCE π
5.2.1
[Unstable API]: This API is new and subject to refinement. So yes, it's new, it's cute, and it may still get refined β don't act surprised. π₯
π SEE ALSO π
That's the whole page, bestie. Footer says Allegro reference manual and ALLEGRO_GLYPH(3) β no date listed, so that's the sign-off. ππ«Ά
π¦ where this page comes from
- arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms