al_load_ttf_font(3alleg5)

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

✨ NAME ✨

al_load_ttf_font β€” ok bestie this is the Allegro 5 API, and this function is your new obsession πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro5/allegro_ttf.h>

ALLEGRO_FONT *al_load_ttf_font(char const *filename, int size, int flags)

πŸ¦‹ DESCRIPTION πŸ¦‹

So basically, this function loads a TrueType font straight from a file, and it does it using the FreeType library under the hood. And like, not to be dramatic, but FreeType goes hard β€” quoting the FreeType FAQ itself, it supports so many different font formats:

TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT, X11 PCF, and others

Periodt. All of those. πŸ’…

The size parameter tells you how big the font is gonna render, and it's specified in pixels. Here's the tea though β€” the standard font size is measured in units per EM, so if you'd rather specify the size as the total height of glyphs in pixels instead, just pass it as a negative value. Yes, negative. It's giving "trust the process." 🌸

Note: if you want to display text at multiple sizes, you gotta load the font multiple times with different size parameters. No shortcuts, bestie, that's just how it is. 😭

Now, the following flags are supported:

  • ALLEGRO_TTF_NO_KERNING β€” do not use any kerning, even if the font file itself supports it. Like, none. Zero. Nada. πŸ™ˆ
  • ALLEGRO_TTF_MONOCHROME β€” loads it as a monochrome font, which literally means no anti-aliasing of the font gets done. Crispy pixels only. ✨
  • ALLEGRO_TTF_NO_AUTOHINT β€” disables the Auto Hinter, which is enabled by default in newer versions of FreeType. Since: 5.0.6, 5.1.2 ⭐

πŸ‘‘ SEE ALSO πŸ‘‘


That's the whole page, babes 🫢 this was the Allegro reference manual, page al_load_ttf_font(3alleg5) β€” go load some fonts and slay πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from