textout_justify_ex(3alleg4)

πŸ’– textout_justify_ex πŸ’–

okay bestie, so this one lives in the Allegro manual β€” that's the Allegro game programming library, and this page is textout_justify_ex(3alleg4). it's giving "make my text look ✨evenly spaced✨" energy, and honestly? iconic. πŸŽ€


✨ NAME ✨

textout_justify_ex β€” draws justified text within a region, fr fr. part of the Allegro game programming library πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

void textout_justify_ex(BITMAP *bmp, const FONT *f, const char *s, int
x1, int x2, int y, int diff, int color, int bg);

🌸 DESCRIPTION 🌸

so what it does is draw justified text inside the region x1-x2. that's the whole vibe. but here's the tea β˜• β€” if the amount of spare space it's working with is greater than the diff value, it literally gives up and just draws regular left justified text instead. no cap. it's not gonna stretch your words into oblivion, it has boundaries. 🫢

here's the example, keep it exact bestie:

char *lines[] = {"Draws justified text",
                 "within the specified",
                 "x2-x1 area. But not",
                 "T H I S !", NULL};
/* Show the justification marker. */
vline(screen, 200, 0, SCREEN_H-1, makecol(0, 0, 0));
/* Draw all the lines until we reach a NULL entry. */
for (num = 0, y = 0; lines[num]; num++, y += text_height(font))
   textout_justify_ex(screen, font, lines[num], 0, 200,
                      y, 80, makecol(0, 0, 0),
                      makecol(255, 255, 255));

see how it just keeps going until it hits a NULL entry? that's the main character loop right there. πŸ‘‘


πŸ‘€ SEE ALSO πŸ‘€


and that's the whole page bestie, we ate and left no crumbs πŸ’…βœ¨ this was Allegro version 4.4.3, so if your code's acting up, check ur version, mwah πŸŽ€πŸ¦‹πŸ’–