In my current project, im using Allegro5 and PhysFS, and so, im calling al_set_physfs_file_interface() in order to make all subsequent calls to al_fopen() on the calling thread to be handled by PHYSFS_open(). Well at this point, everything is working fine, I can load bitmaps from a zip file, i can even load samples from a zip file... BUT... the ONLY THING thats not working is loading fonts... After calling al_set_physfs_file_interface(), al_load_font() fails no matter if you try to load the font file from a zip file or even from the disk... Any clues on how to solve it?
https://liballeg.org/a5docs/trunk/fshook.html#al_set_standard_fs_interface
EDIT
Please state which versions of allegro, compiler, and OS you are using. If you're using binaries, where did you get them from?
There was an old bug in zlib that was fixed when 3.0.0 came out. You may have caught it. It would cause ttf fonts to fail to load from inside an archive. Solution was to upgrade.
allegro 5.0.10 mingw 4.7.0 got from https://www.allegro.cc/files/
PhysicsFS 3.0.1 got from https://icculus.org/physfs/
OS: Windows 10 Pro
Compiler: CodeBlocks 17.12 (GNU GCC Compiler)
BTW: Heres an example code where you can test what im saying:
#include <D:\CodeBlocks\MinGW\include\physfs\physfs.h>
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_physfs.h>
int main() {
PHYSFS_init(0);
PHYSFS_mount("ADD HERE A PATH FOR A ZIP FILE WHICH MUST CONTAIN THE Arial.ttf font inside"",0,1);
al_init();
al_init_primitives_addon();
al_init_font_addon();
al_init_ttf_addon();
ALLEGRO_DISPLAY *display=al_create_display(100,50);
ALLEGRO_FONT *font;
if(0) {
//Enable this block for the "not working" version
al_set_physfs_file_interface();
font=al_load_ttf_font("Arial.ttf",20,0);
}
else {
font=al_load_ttf_font("C:\\Windows\\Fonts\\Arial.ttf",20,0);
}
al_set_target_backbuffer(display);
al_clear_to_color(al_map_rgb(255,255,255));
al_draw_text(font,al_map_rgb(0,0,0),50,25,ALLEGRO_ALIGN_CENTER,"TEXT");
al_flip_display();
al_rest(2);
return 0;
}
Can you load bitmap fonts?
Edit: probably irrelevant now that I've seen your code. If you're using PhysFS, you might have to use al_load_ttf_font_f instead:
ALLEGRO_FILE* f = al_fopen("Arial.ttf", "r"); ALLEGRO_FONT* arial = al_load_ttf_font_f(f, "Arial.ttf", 12, NULL);
TY verymuch for the fast and friendly help, i really apreciated it, since ppl from coding forums are used to be rude with new users... BUT yesterday i just tried to download the allegro5 AGAIN, in hope they have a new version... Well, looking for the file contents, dll versions, it seems to be the same version as mine, so I even just not tested anything after it... BUT for now, when I was trying to make a better code to show you about the bugs, the font just loaded fine even using the PhysFS and al_set_physfs_file_interface()... Maybe they just fixed it but not changed the version? IDK... I just know that its working fine for now, just using al_load_ttf_font() instead of al_load_ttf_font_f() as you said to do... Anyways, ty again for the help =))))
With binaries that old, zlib 3 hadn't even come out yet. :/
Please do yourself a favor and download either my binaries or SiegeLords (if you prefer MSYS2).
Find them here :
https://www.allegro.cc/forums/thread/617424
And links to SiegeLord's here :
http://members.allegro.cc/EdgarReynaldo/BuildA5.html#official
Please don't download binaries from allegro.cc files page unless you know exactly what you are doing. Those files are 5 years old.
The font bug not loading from an archive was fixed with versions of zlib greater than 3.
Ty mate, i'll check it out later =)
Edgar : I have observed that most of the new comers to Allegro 5 use 5.0.10 and this was the version I used when I started.
Its may be because the two famous YouTube channels which teach allegro 5 are using 5.0.10. Prior to Allegro I didn't know that it was possible to do so much in C/C++, it was a common misconception among freshers that it's just a terminal oriented language and when I told my friends that it's possible to do much more with Allegro 5 they were overjoyed and started learning. We all started with 5.0.10 because of video tutorials, and they are still using 5.0.10 because it works just fine and there are no video tutorials teaching you how actually this static and dynamic linking works. If someone make a post or article on allegro.cc on how to configure newer versions of Allegro with how to link it statically and dynamically then it will be very good. When I was a total beginner I was unable to link the new version to my project so I used 5.0.10. It will be really nice of you if you can do it. I don't know how to post an article on allegro.cc so...
I think it's probably because this page lists it as the latest version.
sthompson : hmm, I think whether someone goes to allegro.cc page or YouTube the result is going to be same. the person is led to believe that 5.0.10 is the latest version.
I think those YouTube channels also thought that it's latest version and they used it in their channels.
I will ask my friend to make a tutorial on installation of Allegro 5.2.4 on Code Blocks. He has a YouTube channel he posts videos on.
Yes please - anything new would be good
Read The Fucking Manual.
then why the '?' sign at the end of "rtfm" ?
Read The Fine Manual...
The information is all out there, just no one takes the time to read it. :/
Granted, most people who start using allegro are complete newbs who don't know how to compile or link a program much less a library.
allegro.cc is not liballeg.org nor is it the wiki. All the outdated content gets a little old sometimes.
So when I say rtfm? I'm asking a question. Have you read the manual?
Not you in particular Doctor Cop, you've been a very solid learner and I like your attitude. So don't take offense. It wasn't so much directed towards you as the people who are too lazy to read.
Edgar is such a good soul.