al_draw_multiline_text(3)
β¨ al_draw_multiline_text β the Allegro 5 API glow-up β¨
okay so bestie, this one lives in the Allegro 5 API manual, and it's literally the multiline text queen. if you've ever wanted to draw a whole paragraph instead of one sad little line, this is your girl π
πΈ SYNOPSIS πΈ
#include <allegro5/allegro_font.h>
void al_draw_multiline_text(const ALLEGRO_FONT *font,
ALLEGRO_COLOR color, float x, float y, float max_width, float line_height,
int flags, const char *text)
π DESCRIPTION π
So it's basically al_draw_text(3) but with main character energy β it draws multiple lines of text. It breaks your text into lines based on what's actually in the string and on the max_width parameter. Then those lines get laid out vertically according to the line_height parameter, and each one is drawn exactly as if you'd called al_draw_text(3) on it. cute, right? π
A newline \n in the text causes a "hard" line break right after it appears in the string. Anything after a hard break goes on a new line, periodt. Carriage return \r is not supported β it will not cause a line break, and it'll probably get drawn as a square or a space depending on the font. so like, don't bother π
The max_width parameter controls the maximum desired width of the lines. This function will try to introduce a "soft" line break after the longest possible series of words that will fit in max_length when drawn with the given font. ngl a "soft" line break can happen either on a space or a tab (\t) character. β¨
But listen β it's totally possible that max_width is too small, or that the words in text are too long to fit in max_width when drawn with font. In that case, the word that's too wide just gets drawn completely on a line by itself. no cap. If you don't want the text overflowing max_width to be visible, then use al_set_clipping_rectangle(3) to clip it off and hide it. very much the move π«Ά
The lines that text got split into will each be drawn using the font, x, color and flags parameters, vertically starting at y and with a distance of line_height between them. And if line_height is zero (0), then the value returned by calling al_get_font_line_height(3) on font gets used as the default instead. slay π«
These flags get honoured by this function, and yes she's picking favorites:
ALLEGRO_ALIGN_LEFTALLEGRO_ALIGN_CENTREALLEGRO_ALIGN_RIGHTALLEGRO_ALIGN_INTEGER
And if you wanna calculate the size of what this function will draw without actually drawing it, or if you need a complex and/or custom layout, you can use al_do_multiline_text(3). iykyk π
β SINCE β
5.1.9 β vintage but iconic π¦
π SEE ALSO π
okay that's the whole page bestie, go forth and draw some paragraphs π
this came from the Allegro reference manual, dated with the al_draw_multiline_text(3) footer β mwah, enjoy the lore πβ¨
π¦ where this page comes from
- arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms