|
default "font" in Allegro5 |
anto80
Member #3,230
February 2003
|
Hello all, ___________ |
Arthur Kalliokoski
Second in Command
February 2005
|
Pretty sure there isn't, but using ttf fonts isn't hard. 1#include <allegro5/allegro_ttf.h> //true type font handling
2
3char ttf_filename[] = "DejaVuSans.ttf";
4
5int main(int argc, char **argv)
6{
7 yadda
8 yadda
9ALLEGRO_FONT *myfont; //Pointer to our True Type font
10ALLEGRO_COLOR white; //a color for text output
11 yadda
12 yadda
13 al_init_font_addon();
14 al_init_ttf_addon();
15 yadda
16 yadda
17 white = al_map_rgb(255,255,255); //set color values to match the names
18
19 myfont = al_load_font(ttf_filename,-28,0); //the negative sign means use 28 pixels high rather than 28 points (supposedly 72'nds of an inch)
20 if(!myfont)
21 {
22 error stuff
23 }
24
25//in render loop
26al_draw_textf(myfont,white,20.0,70.0,0,"cumulative frames %8u",frames);
They all watch too much MSNBC... they get ideas. |
Thomas Fjellstrom
Member #476
June 2000
|
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. -- |
anto80
Member #3,230
February 2003
|
I agree with you all: ___________ |
Arthur Kalliokoski
Second in Command
February 2005
|
anto80 said: 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. They all watch too much MSNBC... they get ideas. |
Thomas Fjellstrom
Member #476
June 2000
|
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. -- |
Arthur Kalliokoski
Second in Command
February 2005
|
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. They all watch too much MSNBC... they get ideas. |
SiegeLord
Member #7,827
October 2006
|
Err... what? "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Arthur Kalliokoski
Second in Command
February 2005
|
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. They all watch too much MSNBC... they get ideas. |
SiegeLord
Member #7,827
October 2006
|
You could always scale it up using transformations, but in principle it's only meant to be used for debugging. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Thomas Fjellstrom
Member #476
June 2000
|
whups. I thought it wasn't there for some reason -- |
anto80
Member #3,230
February 2003
|
Thanks again for all new replies. ___________ |
|