In addition to the functions that Miran pointed out, you would need a function for finding the length of each character. Unfortunately, the only way you can do this in the Allegro public API is by converting each character into a string (copying it to a buffer that is followed by a terminating \0) and using text_length() on the string. However, the internal API has a char_length() method for the font, which will come in useful as we need to measure each character. To make use if it, add the line #include <allegro/internal/aintern.h> to the file where the multiline text-out code is stored.
It just so happens that I've written some code to do just that, so I thought I'd share it (see attatchment). The code can handle unicode characters (although this is currently untested).
[EDIT]The code can also handle newline characters, and prints the wrapped lines justified.[/EDIT]
Use the function aeGetNumTextLinesWithLengthLimit() to get the number of lines that the rendered text will take up, and aeTextoutMultiline() to actually render the text. The code is well commented (it even uses Doxygen-style comments so it can automatically generate docs if passed through Doxygen).
There are still a few things I could do to improve the code. Currently, the code uses a static buffer for the output of each line. This is determined by AEMULTILINEBUFSIZE (currently 512). Also, the code does not do tabs or hyphens, and the helper-function aeAdvanceToStartOfCurrentLineandGetNextLine() could be split into two separate functions.
Anyway, let me know if this is what you're after.