text_length(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

✨ text_length(3) ✨

okay so bestie, welcome to the Allegro manual πŸ’– this one's called text_length and it's literally the glow-up you need when you're out here trying to figure out how WIDE your text is gonna be. no cap.


🌸 NAME 🌸

text_length</ppurple> β€” returns the length of a string in pixels. it's part of the Allegro game programming library, iykyk πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

int text_length(const FONT *f, const char *str);

πŸ’… DESCRIPTION πŸ’…

so like. it returns the length β€” in pixels β€” of a string, measured in the font you picked. that's it. that's the whole vibe. periodt. πŸ‘‘

here's the moment you've been waiting for, an actual example:

int width = text_length(font, "I love spam");
...
bmp = create_bitmap(width, height);

the way that just WORKS 😭 you get the width, you make the bitmap, you slay. main character energy fr fr.


🌈 SEE ALSO 🌈


and that's the whole page, bestie!! 🫢 this one came to you from the Allegro girlies, version 4.4.3 βœ¨πŸ’– go forth and measure your strings, you absolute icon πŸŽ€πŸ¦‹πŸ’…

πŸ“¦ where this page comes from