---
name: "al_do_multiline_text"
section: "3"
platform: "linux"
package: "allegro"
version: "5.2.11.3-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/al_do_multiline_text"
---

# al\_do\_multiline\_text(3)

Allegro 5 API

## NAME

al\_do\_multiline\_text - Allegro 5 API

## SYNOPSIS

-

  ```
  #include <allegro5/allegro_font.h>
  void al_do_multiline_text(const ALLEGRO_FONT *font,
     float max_width, const char *text,
     bool (*cb)(int line_num, const char *line, int size, void *extra),
     void *extra)
  ```

## DESCRIPTION

This function processes the `text` and splits it into lines as [al\_draw\_multiline\_text(3)](/al_draw_multiline_text/3.md) would, and then calls the callback `cb` once for every line. This is useful for custom drawing of multiline text, or for calculating the size of multiline text ahead of time. See the documentation on [al\_draw\_multiline\_text(3)](/al_draw_multiline_text/3.md) for an explanation of the splitting algorithm.

For every line that this function splits `text` into the callback `cb` will be called once with the following parameters:

- •

  `line_num` - the number of the line starting from zero and counting up

- •

  `line` - a pointer to the beginning character of the line (see below)

- •

  `size` - the size of the line (0 for empty lines)

- •

  `extra` - the same pointer that was passed to al\_do\_multiline\_text

Note that `line` is *not* guaranteed to be a NUL-terminated string, but will merely point to a character within `text` or to an empty string in case of an empty line. If you need a NUL-terminated string, you will have to copy `line` to a buffer and NUL-terminate it yourself. You will also have to make your own copy if you need the contents of `line` after `cb` has returned, as `line` is *not* guaranteed to be valid after that.

If the callback `cb` returns false, al\_do\_multiline\_text will stop immediately, otherwise it will continue on to the next line.

## SINCE

5\.1.9

## SEE ALSO

[al\_draw\_multiline\_text(3)](/al_draw_multiline_text/3.md)
