al_get_glyph_dimensions(3)
πΈ 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