load_font(3)

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

✨ load_font β€” the manual page, but make it cute ✨

okay bestie, gather round, because this is load_font(3) from the Allegro manual β€” yes, the game programming library, and yes, she's iconic πŸ’…


🌸 NAME 🌸

load_font β€” loads a font from a file. Allegro game programming library. that's it, that's the vibe πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

FONT *load_font(const char *filename, RGB *pal, void *param);

like. look at her. three args. flawless. no notes πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

So load_font loads a font from a file, periodt. rn it supports pulling fonts from a GRX format .fnt file, an 8x8 or 8x16 BIOS format .fnt file, a datafile, or literally any bitmap format that load_bitmap() can handle. versatile queen πŸ’…

if the font is packing palette information, that palette gets returned in the second parameter, which should be an array of 256 RGB structures β€” aka a PALETTE. and get this: the pal argument can be NULL 🫢 in that case, the palette data, if it's even there, is simply not returned. no drama, it just doesn't come back.

the third parameter is your lil secret tunnel β€” you can use it to pass specific info to a custom loader routine. normally tho? you just leave it as NULL, bestie, it's fine. also lowkey important: another way of loading fonts is embedding them into a datafile and using the datafile related functions πŸ‘€ iykyk

Example, because we love a demo:

FONT *myfont;
PALETTE palette;
...
myfont = load_font("my_font.pcx", palette, NULL);
if (!myfont)
   abort_on_error("Couldn't load font!");
...
textout_centre_ex(screen, myfont, "This is my own pretty font!",
                  SCREEN_W / 2, SCREEN_H / 2, white, black);
...
destroy_font(myfont);

not the abort_on_error in the middle of the demo 😭 safety first tho fr fr


πŸ”₯ RETURN VALUE πŸ”₯

Returns a pointer to the font, or NULL on error. and listen β€” you are responsible for destroying the font when you are finished with it, because otherwise you get memory leaks and nobody wants that energy πŸ’€ call destroy_font() when you're done. clean up after yourself, main character behavior only ✨


🌈 SEE ALSO 🌈

the whole font-loading friend group, honestly 🫢 go read them too


okay that's the page!! this was the Allegro manual, version 4.4.3, and the page itself is load_font(3) β€” mwah, kiss the footer goodbye, thanks for reading bestie πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from