register_font_file_type(3)

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

✨ register_font_file_type ✨

okay bestie, gather round, because we're about to talk about register_font_file_type(3) from the Allegro manual β€” aka the Allegro game programming library, aka the icon that raised us πŸ’–


🌸 NAME 🌸

register_font_file_type β€” it's literally the function that lets you teach Allegro a brand new font format. Register a new font loading function, that's the whole vibe. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

void register_font_file_type(const char *ext, FONT *(*load)(const char *filename, RGB *pal, void *param));

no cap, that's the whole signature, character for character, do not touch it πŸ’…


πŸ‘‘ DESCRIPTION πŸ‘‘

So here's the tea, bestie: this function informs the load_font() functions of a new file type, and it hands them a routine that knows how to read fonts in that format. It's giving "hey Allegro, I gotchu, I'll handle this extension myself" energy. ✨

The function you supply has to follow this prototype, exactly:

FONT *load_my_font(const char *filename, RGB *pal, void *param)
{
   ...
}

like, that's the shape it has to be. no negotiations. 🫢

Now, let's talk about those parameters because they matter:

  • The pal parameter can optionally be used to return a palette for the FONT. optional though β€” she's flexible like that. 🌈
  • The param parameter can be anything you like. literally anything. You can use it to pass information to your loading routine, such as for instance the font height, the character range to load, or the index number of a font in a datafile. it's your little secret-passing pocket. πŸ“
⚠️ and this part is important, so listen up: if you choose to write your own font loading code, your function should be prepared to deal with a value of NULL for either of these parameters. both of them. NULL can show up unannounced and your function needs to not spiral about it. 😭

πŸ”₯ SEE ALSO πŸ”₯

  • load_font(3) β€” the one who actually calls your fancy new loader. go say hi. πŸ’–

and that's the page, bestie!! this was Allegro, version 4.4.3, and it's the register_font_file_type(3) page, mwah πŸ’…βœ¨

πŸ“¦ where this page comes from