text_height(3alleg4)

πŸ’– text_height πŸ’–

okay bestie so this is text_height from the Allegro game programming library β€” it's a 3alleg4 manual page and it's literally the simplest little glow-up of a function. it tells you how tall a font is, in pixels. that's it. that's the whole vibe. and yet?? you need it. every single time. πŸŽ€


✨ NAME ✨

text_height β€” returns the height of a font in pixels. Allegro game programming library. no cap, that's the entire job description πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

int text_height(const FONT *f)

she's short, she's sweet, she takes one (1) argument and gives you a number. main character energy fr fr πŸ¦‹


🫢 DESCRIPTION 🫢

so like. you hand her a font β€” the specified font, f β€” and she hands you back the height in pixels. that's the whole deal. it's giving "trust me bestie, you're gonna need this number in like five seconds."

and here's why you need it: fonts are not all the same size, and if you're about to make a bitmap to draw text into, you can't just guess. you ask. like this:

int height = text_height(font);
...
bmp = create_bitmap(width, height);

see?? she's feeding height straight into create_bitmap. iconic behaviour honestly. 🌈

ngl this is the kind of function that seems boring until you hardcode a font height and everything is visibly wrong on someone else's machine. ask the font. she knows her own height. periodt.

πŸ”₯ SEE ALSO πŸ”₯

go read these next bestie, they're all in the same friend group:


and that's the page!! mwah πŸ’‹ this one's from Allegro, version 4.4.3, and the page itself is text_height(3alleg4). stay tall, stay pixel-accurate, and go measure a font. i'm obsessed with you. bye!! πŸŽ€βœ¨πŸ¦‹πŸ’–