1al_draw_multiline_text(3) al_draw_multiline_text(3)
2
3
4
6 al_draw_multiline_text - Allegro 5 API
7
9 #include <allegro5/allegro_font.h>
10
11 void al_draw_multiline_text(const ALLEGRO_FONT *font,
12 ALLEGRO_COLOR color, float x, float y, float max_width, float line_height,
13 int flags, const char *text)
14
16 Like al_draw_text(3), but this function supports drawing multiple lines
17 of text. It will break text in lines based on its contents and the
18 max_width parameter. The lines are then layed out vertically depending
19 on the line_height parameter and drawn each as if al_draw_text(3) was
20 called on them.
21
22 A newline \n in the text will cause a “hard” line break after its oc‐
23 currence in the string. The text after a hard break is placed on a new
24 line. Carriage return \r is not supported, will not cause a line
25 break, and will likely be drawn as a square or a space depending on the
26 font.
27
28 The max_width parameter controls the maximum desired width of the
29 lines. This function will try to introduce a “soft” line break after
30 the longest possible series of words that will fit in max_length when
31 drawn with the given font. A “soft” line break can occur either on a
32 space or tab (\t) character.
33
34 However, it is possible that max_width is too small, or the words in
35 text are too long to fit max_width when drawn with font. In that case,
36 the word that is too wide will simply be drawn completely on a line by
37 itself. If you don’t want the text that overflows max_width to be vis‐
38 ible, then use al_set_clipping_rectangle(3) to clip it off and hide it.
39
40 The lines text was split into will each be drawn using the font, x,
41 color and flags parameters, vertically starting at y and with a dis‐
42 tance of line_height between them. If line_height is zero (0), the
43 value returned by calling al_get_font_line_height(3) on font will be
44 used as a default instead.
45
46 The flags ALLEGRO_ALIGN_LEFT, ALLEGRO_ALIGN_CENTRE, ALLEGRO_ALIGN_RIGHT
47 and ALLEGRO_ALIGN_INTEGER will be honoured by this function.
48
49 If you want to calculate the size of what this function will draw with‐
50 out actually drawing it, or if you need a complex and/or custom layout,
51 you can use al_do_multiline_text(3).
52
54 5.1.9
55
57 al_do_multiline_text(3), al_draw_multiline_ustr(3), al_draw_multi‐
58 line_textf(3)
59
60
61
62Allegro reference manual al_draw_multiline_text(3)