SFML community forums
Help => Graphics => Topic started by: quicksilver on March 11, 2013, 06:57:39 pm
-
I'm using Ubuntu 12.04 and Code::Blocks 12.11. I cloned the SFML 2.0 source and built it on my system.
Everything works fine when I run my app from Code::Blocks itself (graphics, sound, font). When I try to open the application from a terminal, however, I get "failed to load font ... (failed to create the font face)."
I have the font copied in the respective bin folders (Release and Debug), so the file path shouldn't be the issue. I am linking to the Release versions of the so files.
Any help?
Thanks in advance.
-
Are both the executable and the resources files located in the working directory (the one from which you launch the executable?)
-
They are. Both the executable and its resources (only the font file in this particular app) are located in the same directory in each case (Code::Blocks creates executables in both bin/Release and bin/Debug).
-
If you run the application within Code::Blocks the default working directory will be next to the project file and thus the application will search there.
-
I understand that, and I have taken that into account. My project folder has the font file in it, as do both my Release and Debug folders. I don't think this is the problem.
-
Update:
I put the absolute file path into the loadFromFile() function and the font loaded from the terminal. However, for any relative path such as "fontfile.ttf" or "./fontfile.ttf", I still get errors (the font file is placed directly with the executable and not in any sub-directories).
I'm used to Code::Blocks 10.04, could this be some change in the newer version?
-
both we have same problem
I solved with this method ./fonts/arial.ttf
-
You first need to cd into the directory in which the font file is, and then start the app. Just copying the full path of you executable won't change your working directory to the path of the executable.