make_trans_font(3)
π 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 π
is_trans_font(3)β check if a font already got the transparency treatmentset_alpha_blender(3)β turn on the alpha blender for that anti-aliased goodnessload_font(3)β go get yourself a font in the first placedraw_trans_sprite(3)β the sprite-drawing function every glyph now goes through
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
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms