al_get_text_dimensions(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ al_get_text_dimensions β€” Allegro 5 API ✨

okay bestie, so you know how we're out here in the Allegro 5 API trying to place text exactly where we want it? yeah. this is the girl for that job. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro5/allegro_font.h>

void al_get_text_dimensions(const ALLEGRO_FONT *f,
   char const *text,
   int *bbx, int *bby, int *bbw, int *bbh)

πŸ’– DESCRIPTION πŸ’–

so like, sometimes al_get_text_width(3alleg5) and al_get_font_line_height(3alleg5) are just… not giving enough?? they're iconic, we love them, but if you need exact text placement they lowkey leave you hanging. that's where this function comes in β€” it returns some additional information so you can actually do the thing. 🫢

the returned variables (all in pixels, no cap):

  • x, y β€” offset to the upper left corner of the bounding box.
  • w, h β€” dimensions of the bounding box.
⚠️ heads up bestie: glyphs can go to the left and upwards of the X, and when that happens, x and y will be negative values. not a bug, just the vibe. 😭

🌈 SEE ALSO 🌈


k that's the whole page, you ate it, go place some text perfectly fr fr πŸ’œ

signing off from the Allegro reference manual β€” this was al_get_text_dimensions(3alleg5), and yes the manual name is right there in the title because we keep it cute and consistent βœ¨πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from