ALLEGRO_GLYPH(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

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