load_font
Loads a font from a file.
Description
Loads a font from a file. At present, this supports loading fonts from
a GRX format .fnt file, a 8x8 or 8x16 BIOS format .fnt file, a datafile or
any bitmap format that can be loaded by load_bitmap().
If the font contains palette information, then the palette is returned in
the second parameter, which should be an array of 256 RGB structures
(a PALETTE). The pal argument may be NULL. In this case, the palette data,
if present, is simply not returned.
The third parameter can be used to pass specific information to a custom
loader routine. Normally, you can just leave this as NULL. Note that
another way of loading fonts is embedding them into a datafile and using
the datafile related functions.
Example:
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(bmp);
Returns a pointer to the font or NULL on error. Remember that you are
responsible for destroying the font when you are finished with it to
avoid memory leaks.
Related Discussions
The following threads each have code containing this keyword:
Note: You can click on the numbers to jump directly to the posts that reference this page.
Related Projects
The following projects include source code containing this keyword: