al_get_glyph_dimensions(3alleg5)
π al_get_glyph_dimensions β Allegro 5 API π
okay bestie, gather round, because today we're getting into the nitty gritty of glyph geometry. this is page al_get_glyph_dimensions(3alleg5) from the Allegro reference manual, and she is lowkey a queen. let's go π
β¨ 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 π¦
so likeβ¦ sometimes al_get_glyph_width(3alleg5) or al_get_glyph_advance(3alleg5) just aren't giving what needs to be gave π. if you need exact glyph placement, this function is your girl β she hands over extra info, and she's especially iconic if you wanna draw the font vertically. main character energy fr fr.
the function returns true if the character was present in the font, and false if it was not present in the font. simple as. π
the returned variables, all in pixels:
bbx,bbyβ offset to the upper left corner of the bounding box π¦bbw,bbhβ dimensions of the bounding box π
these values are literally the same as what al_get_text_dimensions(3alleg5) would return for a string of a single character equal to the glyph you passed in here. no cap. and heads up: glyphs may go to the left and upwards of the X, in which case x and y will have negative values. not a bug, just vibes. π
if you wanna draw a string vertically (think Japanese text, or just a cute game effect β¨), then you should leave bby + bbh space between the glyphs in the y direction for a regular placement.
if you wanna 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.
and 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(). study her. she's art. πΌοΈ
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 β she's been serving since 5.1.12, an icon of her era π
π SEE ALSO π
and that's the whole page, bestie!! π«Ά this was the Allegro reference manual, al_get_glyph_dimensions(3alleg5), and that lil footer down there said Allegro reference manual β al_get_glyph_dimensions(3alleg5). mwah, go forth and place your glyphs with precision πβ¨π
π¦ where this page comes from
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms