Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » default "font" in Allegro5

Credits go to Arthur Kalliokoski and Thomas Fjellstrom for helping out!
This thread is locked; no one can reply to it. rss feed Print
default "font" in Allegro5
anto80
Member #3,230
February 2003
avatar

Hello all,
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.

___________
Currently working on his action/puzzle game CIPHER PUSHER : Blocks/Vortexes/Seafood! Facebook - Twitter - webpage

Arthur Kalliokoski
Second in Command
February 2005
avatar

Pretty sure there isn't, but using ttf fonts isn't hard.

#SelectExpand
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
avatar

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.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

anto80
Member #3,230
February 2003
avatar

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)
Thanks anyway.

___________
Currently working on his action/puzzle game CIPHER PUSHER : Blocks/Vortexes/Seafood! Facebook - Twitter - webpage

Arthur Kalliokoski
Second in Command
February 2005
avatar

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
avatar

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.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Arthur Kalliokoski
Second in Command
February 2005
avatar

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
avatar

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

Arthur Kalliokoski
Second in Command
February 2005
avatar

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
avatar

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
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Thomas Fjellstrom
Member #476
June 2000
avatar

whups. I thought it wasn't there for some reason :(

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

anto80
Member #3,230
February 2003
avatar

Thanks again for all new replies.

___________
Currently working on his action/puzzle game CIPHER PUSHER : Blocks/Vortexes/Seafood! Facebook - Twitter - webpage

Go to: