So i've been using Allegro 5 to create a client and I just recently got to the font part. I started off by trying to load the arial TTF font. It failed. The odd thing about this is I had made another program using the exact same font(it was identical code) and it worked on my other computer. But it fails here. I am quite confused right now why this could be.
The order that I initialize the addons. Not sure if it matters.
The peice of code where I try to retrieve the font.
ALLEGRO_FONT *font = al_load_font("arial.ttf", 12, 0);
If there is any additional information you need to know then you're welcome to ask me. I would just like to solve this problem so I can continue on.
Have you tried:
The logic here is that you are trying to turn on the radio without first putting the key in the ignition
I just tried replacing it with my old code and it didn't seem to fix anything.
Edit: I do get your logic now
Another thing I might need to add is that i'm using 4.9.22. Not sure if there was a bug in it that was solved in another version or something.
hmmm
maybe you can check if anything is not initing...
Although I doubt this is the problem, maybe font is being mangled with something else since it is a common name. Maybe try arialFont instead.
I used 4.9.22 for a while with no problems,
Here is my cheezy, messy, testbed for my gui api,
maybe you can find your answer somewhere it it
If you want to post your code, I'll look and see if I see something fishy
I tried checking if it fails initializing but it doesn't. Then I copied the arial font into the folder and tried that, nothing. Then I renamed the arial font to arialFont.ttf and still nothing. Not sure what else it could be.
Edit: I'm really bad at reading text after code. I saw the code then skipped over that last message of me showing you that code. Anyways, I don't want to throw it all at you so i'll just give you the file that it is in. If you think it could be anything else tell me.
Note: I do use a A5 wrapper class that a friend of mine has made. It pretty much is the same as any others code. And so you know, when something doesn't work I try to comment it out and make it more simple. I remove it all once I fix it
what I meant was your ALLEGRO_FONT *font to become ALLEGRO_FONT *arialFont
Just tried that as well. Didn't affect anything.
did you check the return value of al_init_ttf_font_addon() ?
Then the best I can do is ask you to post some code so I can look through it for errors
Does ex_ttf work, with the supplied font or arial.ttf?
Yes William I did and it is fine. I'll post the code, it'll have to be a few files of coding.
Note: I do use a5ses(Allegro 5 Sepples Edition, just a C++ wrapper). I am quite sure that it is not the problem because the creator has gotten the font to work before. If you would like to research it just in case, this is the link: a5ses.
Now, the next file is in "renderer/States/MainMenu.cpp". Most of this code I don't believe is relevant until you get to the part where it loads the font. So you know, I started with a5::Font, moved to al_load_font, and finally al_load_ttf_font. They all had failed.
If there is any other peices of code that you'd like to see(I decided not to show the client class or the gui class) then just ask.
Geez, i'm really sorry, I've looked through several times and see nothing wrong with your code , I really wish I could do more to help but I don't know at this point, hopefully someone else will know
I saw the A5 wrapper is called 4.9.21.2 and you use 4.9.22, I don't know if that could be it, just putting it out there.
Yeah the creator is lazy I manually updated to 4.9.22 and made sure everything is the same. Another friend of mine uses 4.9.22 and also uses the wrapper and said font loading worked fine.
To answer Peter's question, I just tried to compile ex_ttf.c and it worked fine. Maybe I should analyze my code with the example and see if I see anything different.
Edit: I have an idea. I will use the debug version of the .ttf and see where exactly it fails. I will edit this post to show my results.
A weird thing I noticed while just screwing around with the code is that it loads the font fine when it's in the main function, but when it goes to LoadMainMenu it fails there.
If the main menu executes on a different thread than it will fail. I don't know if that is your case.
Alright, I think we're getting closer and closer to solving this. I found another peice of interesting information. It seems that it loads the font fine only if it's before this line of code in main "Client *client = new Client();" and after it it will always fail. Here is what the constructor contains. Any ideas on how to fix it or what might be causing it?
Check what settings.read() and new Renderer() do. Maybe the the file interface gets changed or bitmap flags are set.
settings.Read is just opening a file to read line by line. I doubt it's the problem. But I do think it may be new Renderer. Here is the constructor. This is where the screen is created, so that may be the problem.
What does the font loader do? Why do array brackets [] take in a cstring?
Don't worry about that. settings is a Config class. The Config classes base is a map. So if this is the config file:
Test = 0
Rawr = no
The Config class would have this in the array:
Test => 0
Rawr => "no"
I'm almost positive of the problem now. I was using PHYSFS for loading bitmaps and it was calling al_set_physfs_interface inside the BitmapLoader interface. So I decided to call it in the main function instead but it's still having problems.
Edit: Finally solved it. God, it was so simple, but that's how most of my errors go. The problem was that I was using PHYSFS and whenever it was searching for the font, it was looking in the search paths. Thank you all for the help.