- Online Community Forums » Programming Questions » Using non-ttf fonts or default text in Allegro 5

This thread is locked; no one can reply to it. rss feed Print
Using non-ttf fonts or default text in Allegro 5
Member #14,123
March 2012

I only need basic text output in a low resolution, 4-bit display. I gather from my readings that Allegro previously had a default font. Does it still?

Assuming I would have to load my own, I find vgasys.fon (common on Windows systems) to be just fine. Note it is not a TTF. If I have to resort to this moving forward, how could I use this minimal font? Utilizing TTF routines not only seems unnecessary, it also does a terrible job at display a .FON. I'm assuming because it is not supported.

Member #7,827
October 2006

Does it still?

No. You can load bitmap fonts, however using al_load_bitmap_font. There is a bitmap font that you can find in the examples/data directory. I think it's called a4font.tga or something.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Member #14,123
March 2012

Correct me if I am wrong, but I think you are referring to a4_font.tga.

Thanks for pointing me in the right direction.

I'm getting this thrown when setting the first parameter in the al_draw_text routine as type ALLEGRO_FONT:

Assertion fail: font, file allegro-5.0.x\addons\font\text.c, line 73

Generic example of what I am doing:

1#include <stdio.h> 2#include <allegro5/allegro.h> 3#include <allegro5/allegro_font.h> 4 5int main(int argc, char **argv) 6{ 7 ALLEGRO_DISPLAY *display = NULL; 8 9 if(!al_init()) { 10 fprintf(stderr, "failed to initialize allegro!\n"); 11 return -1; 12 } 13 14 display = al_create_display(320, 200); 15 if(!display) { 16 fprintf(stderr, "failed to create display!\n"); 17 return -1; 18 } 19 20 al_init_font_addon(); 21 22 ALLEGRO_FONT *font = al_load_bitmap_font("a4_font.tga"); 23 24 al_clear_to_color(al_map_rgb(0,0,0)); 25 al_draw_text(font, al_map_rgb(255,255,255), 0,0,0, ""); 26 27 al_flip_display(); 28 29 al_rest(10.0); 30 31 al_destroy_display(display); 32 33 return 0; 34}

Peter Wang
Member #23
April 2000

You need the image addon to load bitmap fonts. See ex_font.c

Member #14,123
March 2012

Thank you.

Go to: