make_trans_font(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– make_trans_font β€” the Allegro manual, bestie edition πŸ’–

okay so this is a page from the Allegro manual, and today we're talking about make_trans_font, which lives in section 3 (library calls, iykyk). buckle up, it's short but it's iconic ✨


🌸 NAME 🌸

make_trans_font β€” makes a font use transparency. part of the Allegro game programming library πŸŽ€


✨ SYNOPSIS ✨

#include <allegro.h>

void make_trans_font(FONT *f);

like, that's it. one function, one pointer, zero drama πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so bestie, here's the tea: this function converts a font to use transparency for drawing. what does that actually mean? it means every single glyph in the font gets drawn with draw_trans_sprite, which is the whole point β€” because now you can use the same blenders you'd use with draw_trans_sprite to draw the font. the font and the sprite are literally in the same blender club now, no cap 🫢

one super common glow-up use for this: load a bitmap font that has an alpha channel, then hit it with Allegro's alpha blender, and boom β€” you get anti-aliased text output. smooth edges. main character typography. it's giving polished. πŸ˜­πŸ’–

here's how to do that, verbatim:

FONT *f = load_font("alphafont.tga", NULL, NULL);
make_trans_font(f);
set_alpha_blender();
textprintf_centre_ex(screen, f, 320, 240, -1, -1, "Anti-aliased Font!");

look at that. three lines of setup and one textprintf_centre_ex and you've got pretty text dead centre of the screen at 320, 240. the -1, -1 for the colour params means "use the font's own colours", and yes it's fine, that's just how it works. slay. ✨

lowkey important: the transparency only kicks in after you call make_trans_font on the font. it's a conversion, not a vibe you can just hope for. πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie, you ate it πŸ“

this was the Allegro manual, version 4.4.3 β€” mwah, periodt πŸ’œπŸ§š

πŸ“¦ where this page comes from