al_get_glyph_dimensions(3)

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

🌸 NAME 🌸

al_get_glyph_dimensions β€” Allegro 5 API, straight outta the Library Functions Manual πŸ’–


✨ SYNOPSIS ✨

              #include <allegro5/allegro_font.h>

              bool al_get_glyph_dimensions(const ALLEGRO_FONT *f,
                 int codepoint, int *bbx, int *bby, int *bbw, int *bbh)

πŸ’– DESCRIPTION πŸ’–

okay so sometimes al_get_glyph_width(3) or al_get_glyph_advance(3) just aren’t enough when you need exact glyph placement, and this function hands you some extra info β€” especially if you’re trying to draw the font vertically. ✨

The function itself returns true if the character was present in font, and false if the character was not present in font. 🫢

Returned variables (all in pixel) πŸ‘‡

  • bbx, bby β€” Offset to upper left corner of bounding box.
  • bbw, bbh β€” Dimensions of bounding box.

These values are the same as al_get_text_dimensions(3) would return for a string of a single character equal to the glyph passed to this function. Heads-up though: glyphs may go to the left and upwards of the X, in which case x and y will have negative values. 😭

If you want to draw a string vertically, for Japanese or as a game effect, then you should leave bby + bbh space between the glyphs in the y direction for a regular placement. 🌸

If you want to draw a string horizontally in an extra compact way, then you should leave bbx + bbw space between the glyphs in the x direction for a compact placement. πŸ’…

In the figure below is an example of what bbx and bby may be like for a 2 glyph, and a g glyph of the same font compared to the result of al_get_glyph_width(). πŸ‘‘

                 al_get_glyph_width()     al_get_glyph_width()
                        __|___                   __|__
                       /      \                 /     \
                   bbx    bbw                 bbx   bbw
                  <-->+<------>+           <-->+<----->+   X baseline
                  ^   |        |           ^   |       |
              bby |   |        |       bby |   |       |
                  v   |        |           |   |       |
                  +---+--------+           |   |       |
                  ^   | *****  |           |   |       |
                  |   |*    ** |           v   |       |
              bbh |   |    **  |       bbh +---+-------+
                  |   |  **    |           ^   | ***** |
                  v   |********|           |   |*     *|
                  +---+--------+           |   | ***** |
                                           |   |      *|
                                           |   | *    *|
                                           v   |  **** |
                                           +---+-------+

πŸŽ€ SINCE πŸŽ€

5.1.12 β€” iconic behavior since then, no cap πŸ’œ


πŸ¦‹ SEE ALSO πŸ¦‹

al_draw_glyph(3), al_get_glyph_width(3), al_get_glyph_advance(3).


that’s the whole page, signed off from the Allegro reference manual β€” no date stamped on this one, so no date to report πŸ’–βœ¨

πŸ“¦ 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