Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Problem loading non-bitmaps using physfs

This thread is locked; no one can reply to it. rss feed Print
Problem loading non-bitmaps using physfs
auamidium
Member #9,630
March 2008

I basically have the same problem as this guy,
http://www.allegro.cc/forums/thread/606505
except that I am trying to load a .ttf instead.
My code is very similar to that in the thread.
I don't think the thread I am refering to was ever solved, or I cannot see the solution.

Bitmaps load correctly using
something = al_load_bitmap("something.bmp");

but in
ALLEGRO_FONT * technoid_font = NULL;
...
technoid_font = al_load_font("technoid.ttf",60,0);

technoid_font stays NULL.

The files do exist, I know the paths are correct because the bitmap was properly loaded from in the .zip file. I just don't know what I am doing wrong with the font file. It loaded properly from a normal folder before I started using physfs. Thanks!

It'll be open source if I ever finish it.

Trent Gamblin
Member #261
April 2000
avatar

You're using the wrong function to load a ttf aren't you? It's al_load_ttf_font.

auamidium
Member #9,630
March 2008

Oooops, my bad. I was not copying and pasting. But I am actually using al_load_ttf_font()

It works fine if I comment out all the physfs stuff and just load from in folder, but I want to use physfs because I have hundreds of resource files.

It'll be open source if I ever finish it.

Trent Gamblin
Member #261
April 2000
avatar

The guy in the other thread said he solved it by

Quote:

EDIT: Okay, I solved it.

I removed ALL the libraries I was linking and re-added them in and I think I added in libphysfs.a instead of libphysfs.dll.a by accident. not sure about the difference, I assume one is a statically linked lib. =/

auamidium
Member #9,630
March 2008

I am linking "allegro_physfs-5.0.0-RC4-mt.dll", which I assume is the correct file?

#SelectExpand
1//... 2 3#include <allegro5/allegro.h> 4#include <allegro5/allegro_image.h> 5#include <allegro5/allegro_font.h> 6#include <allegro5/allegro_ttf.h> 7#include <physfs.h> 8#include <allegro5/allegro_physfs.h> 9 10// ... 11 12ALLEGRO_BITMAP *title_screen_bitmap = NULL; 13 14ALLEGRO_FONT *technoid_font = NULL; 15ALLEGRO_FONT *technoid_font_small = NULL; 16 17//... 18 19int main(int argc, char **argv) 20{ 21 //... 22 if(!al_init()) 23 { 24 cout << "failed to initalize allegro!" << endl; 25 return -1; 26 } 27 28 Cout_Debug_Version_Data(); 29 30 if(!al_init_image_addon()) 31 { 32 cout << "failed to iniitalize allegro image" << endl; 33 return -1; 34 } 35 36 ALLEGRO_DISPLAY *display = NULL; 37 display = al_create_display(SCREEN_W, SCREEN_H); 38 if(!display) 39 { 40 cout << "failed to create display!" << endl; 41 return -1; 42 } 43 44 if(!PHYSFS_init(argv[0])) 45 { 46 cout << "failed PHYSFS init" << endl; 47 return -1; 48 } 49 50 if(PHYSFS_mount("resources.zip", "/", 1) == 0) 51 { 52 cout << "Could not find resources.zip" << endl; 53 return -1; 54 } 55 56 al_set_physfs_file_interface(); 57 al_init_font_addon(); 58 al_init_ttf_addon(); 59 60 // init other stuff... 61 62 //... 63 64 title_screen_bitmap = al_load_bitmap("title_screen_bitmap.bmp"); 65 if(title_screen_bitmap == NULL) 66 { 67 cout << "problems" << endl; 68 69 } // works fine, no problems 70 71 technoid_font = al_load_ttf_font("TECHNOID.ttf",60,0); 72 technoid_font_small = al_load_ttf_font("TECHNOID.ttf",30,0); 73 74 if(technoid_font == NULL || technoid_font_small == NULL) 75 { 76 cout << "text loading failed" << endl; 77 return -1; 78 } //couts text loading fail and quits 79 80// Everything else 81 82}

Edit: I changed to technoid_font_small = al_load_ttf_font("TECHNOIDS.ttf",30,0); and it works. Is it that I cannot load the same file twice? :P Thanks though.

It'll be open source if I ever finish it.

Neil Walker
Member #210
April 2000
avatar

I don't really know A5, but does al_filename_exists return true?

[edit]ah, well scrap my reply I never saw your update.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Edgar Reynaldo
Member #8,592
May 2007
avatar

auamidium said:

Edit: I changed to technoid_font_small = al_load_ttf_font("TECHNOIDS.ttf",30,0); and it works. Is it that I cannot load the same file twice? :P Thanks though.

Maybe 60 just isn't supported for that font? I don't know how Allegro handles sizes that aren't in the font.

Arthur Kalliokoski
Second in Command
February 2005
avatar

Maybe 60 just isn't supported for that font? I don't know how Allegro handles sizes that aren't in the font.

TTF fonts are drawn using math functions, they don't really have a minimum or maximum size. I learned this a couple few months ago. Time flies when you're having fun!

http://www.allegro.cc/forums/thread/604975/881025

OTOH, I hung the entire box fiddling with an insanely huge font (don't remember the size) and after I rebooted the log files said there had been a crash in the video driver.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Edgar Reynaldo
Member #8,592
May 2007
avatar

auamidium said:

technoid_font = al_load_font("technoid.ttf",60,0);
...
Edit: I changed to technoid_font_small = al_load_ttf_font("TECHNOIDS.ttf",30,0); and it works. Is it that I cannot load the same file twice? :P Thanks though.

The two calls are different - one has an a 's' and one doesn't, so it was the file name giving you problems, not the font size.

Matthew Leverton
Supreme Loser
January 1999
avatar

He's saying that if he tries to load the same font file twice with different sizes, it fails. If he creates two copies of the font within the same zip file with different names, then he can load them both.

If that is really happening, then it sounds like a bug with Allegro. It should be easy for somebody to reproduce.

Go to: