al_draw_multiline_text(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ 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_LEFT
  • ALLEGRO_ALIGN_CENTRE
  • ALLEGRO_ALIGN_RIGHT
  • ALLEGRO_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