al_draw_multiline_text(3alleg5)
β¨ NAME β¨
okay so bestie, welcome to the <pink>al_draw_multiline_text</pink> manual page, from the <purple>Allegro 5 API</purple> β the one and only <cyan>al_draw_multiline_text(3alleg5)</cyan>. she draws text. multiple lines of it. she's iconic for that π
π 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 like, it's giving <hotpink>al_draw_text(3alleg5)</hotpink> energy, but make it <rainbow>multiline</rainbow> β¨ it draws several lines of text at once, no cap. it decides where to break the lines based on what's actually in the text plus the max_width parameter. then it stacks those lines vertically according to line_height, and draws each one as if you'd called al_draw_text(3alleg5) on it individually. lowkey elegant fr fr.
if you drop a newline \n in the text, that causes a <yellow>"hard"</yellow> line break right after it lands in the string. everything after that hard break gets placed on a new line, periodt. and listen β carriage return \r is <red>NOT supported</red> π it will not cause a line break, and depending on the font it'll probably get drawn as a square or a space. so yeah. don't do that. π
the max_width parameter controls the maximum desired width of the lines. the function will try to sneak in a <mint>"soft"</mint> line break after the longest possible series of words that'll fit in max_width when drawn with the given font. a soft break can happen on either a space or a tab (\t) character. cute, right? πΈ
BUT. plot twist π« it's totally possible that max_width is too small, or the words in text are just too long to fit max_width when drawn with font. in that case, the word that's too wide gets drawn completely on a line by itself. she's too big for the box and she said what she said π if you don't want that overflowing text visible, use al_set_clipping_rectangle(3alleg5) to clip it off and hide it. hide her. π
the lines that the 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(3alleg5) on font gets used as the default instead. automatic glow-up, we love to see it π
these flags get honoured by this function, and yes she honours ALL of them:
ALLEGRO_ALIGN_LEFTALLEGRO_ALIGN_CENTREALLEGRO_ALIGN_RIGHTALLEGRO_ALIGN_INTEGER
and if you wanna calculate the size of what this function would draw without actually drawing it (vibe check before committing, iykyk), or if you need a complex and/or custom layout, then go use al_do_multiline_text(3alleg5) instead. she's right there, she's got you π«Ά
β SINCE β
5.1.9 β she's been serving since way back, a true veteran of the game π
π SEE ALSO π
okay that's the whole page bestie, you ate it up, go draw some slayful multiline text πβ¨ this was the <purple>Allegro reference manual</purple>'s <pink>al_draw_multiline_text(3alleg5)</pink> page, and honestly? she devoured. mwah π
π
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms