al_draw_text(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 5 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

al_draw_text β€” the Allegro 5 API's own little text-slapping bestie ✨

(It lives in the Allegro 5 manual, section 3alleg5, and honestly? She's iconic.)


✨ SYNOPSIS ✨

#include <allegro5/allegro_font.h>

void al_draw_text(const ALLEGRO_FONT *font,
   ALLEGRO_COLOR color, float x, float y, int flags,
   char const *text)

πŸŽ€ DESCRIPTION πŸŽ€

Okay so basically, al_draw_text takes your text β€” which is a NUL-terminated string, no cap β€” and writes it onto the target bitmap at position x, y, using the font you picked. That's it. That's the whole vibe. πŸ¦‹

The flags parameter can be 0, or one of these three:

  • ALLEGRO_ALIGN_LEFT β€” draws the text left-aligned. Lowkey the same thing as 0, bestie. They're literally twins. πŸ‘―
  • ALLEGRO_ALIGN_CENTRE β€” draws the text centered around the given position. Not starting at it, around it. Very main character energy. πŸ‘‘
  • ALLEGRO_ALIGN_RIGHT β€” draws the text right-aligned to the given position.

And you can also combine that with this one:

  • ALLEGRO_ALIGN_INTEGER β€” always draws text aligned to an integer pixel position. This used to be the default behaviour btw, so if you're porting old code and things look slightly off, that's why πŸ™ˆ. Since: 5.0.8, 5.1.4.
πŸ’€ Real talk though: this function does NOT support newline characters (\n). Not even a little. If you want multi-line text output you gotta go use al_draw_multiline_text(3alleg5) instead, fr fr.

🌸 SEE ALSO 🌸


And that's the whole page, bestie 🫢 β€” this one came straight out of the Allegro reference manual, filed under al_draw_text(3alleg5). Go forth and draw some text. Slay. πŸ’…βœ¨

πŸ“¦ where this page comes from