extract_font_range(3alleg4)

✨ extract_font_range ✨

okay bestie, welcome to extract_font_range from the Allegro manual, section 3alleg4 πŸ’– this one's a lil font-surgery situation and it's honestly so useful, i'm obsessed


🌸 NAME 🌸

extract_font_range β€” extracts a range of characters from a font. part of the Allegro game programming library, no cap πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

FONT *extract_font_range(FONT *f, int begin, int end)

πŸ’… DESCRIPTION πŸ’…

so like. this function extracts a character range from a font and hands you back a brand new font that contains only the range of characters you selected with this function. literally just the slice you asked for, nothing else, main character energy only πŸ‘‘

and here's the cute part: you can pass -1 for either the lower or upper bound if you want to select all characters from the start or to the end of the font. so -1 is giving "idk just take everything from here" 🌈

example time, periodt:

FONT *myfont;
FONT *capitals;
FONT *fontcopy;
...
/* Create a font of only capital letters */
capitals = extract_font_range(myfont, 'A', 'Z');

/* Create a copy of the font */
fontcopy = extract_font_range(myfont, -1, -1);
...
destroy_font(capitals);
destroy_font(fontcopy);

look at that. capitals only?? iconic. full copy of the font?? also iconic. slay πŸ’–


πŸŽ€ RETURN VALUE πŸŽ€

returns a pointer to the new font, or NULL on error 😭

bestie. listen. you are responsible for destroying the font when you are finished with it, to avoid memory leaks. that's on you fr fr. don't leave it hanging 🫢

πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, no notes πŸ’œ this was Allegro, version 4.4.3, extract_font_range(3alleg4) β€” go forth and slice those fonts, bestie, you're gonna eat βœ¨πŸ‘‘πŸŒΈ