default "font" in Allegro5
I'm trying to convert an Allegro 4.2 program into Allegro 5.
Is the default font (called 'font') still existing?
Thank you in advance.
Pretty sure there isn't, but using ttf fonts isn't hard.
1#include <allegro5/allegro_ttf.h> //true type font handling
ttf_filename = "DejaVuSans.ttf";
argc, char **
myfont; //Pointer to our True Type font
white; //a color for text output
white = al_map_rgb(255
,255); //set color values to match the names
myfont = al_load_font(
,0); //the negative sign means use 28 pixels high rather than 28 points (supposedly 72'nds of an inch)
25//in render loop
,"cumulative frames %8u"
It's not built in, but allegro distributes the old a4 font with the examples.
Look for 'examples/data/a4_font.tga'.
I wouldn't choose that font for anything these days. If you need a small fixed width font, there are many better ones to choose from.
I agree with you all:
- Using TTF is not hard (and well documented)
- It is possible to load the old a4 font (which is distributed as a bitmap)
but the thing I was trying to do was to display text without the need to use an external file (even if it is ugly)
display text without the need to use an external file
You might be able to include it into the executable as binary and use some sort of memfile function, but it's more work than I want to try.
You can convert the file to a C array, and feed that into a memfile as Arthur hinted at, then use the al_load_bitmap_f to "load" the image.
If you're using gcc, you could use this, for other compilers I don't know, but then you could use the NASM assembler with the %incbin directive along with the object format command line option needed so you can link it in like any other object file.
A great big ODARN echos through the trailer park! I was searching for "default font" etc.
OTOH, 8x8 is too small to be reasonably legible for modern screen pitches.
You could always scale it up using transformations, but in principle it's only meant to be used for debugging.
whups. I thought it wasn't there for some reason
Thread #613729. Printed from Allegro.cc
Thanks again for all new replies.