SFML community forums

Help => General => Topic started by: mateandmetal on February 25, 2013, 10:07:22 pm

Title: (SOLVED) Can´t load Font files under Linux
Post by: mateandmetal on February 25, 2013, 10:07:22 pm
Hi there!
I´m trying to get my game working under Fedora 18 x64
Im using C++ and SFML 2.0 from GitHub (very recent version)

I have created a folder where my font files are stored. Under win7, I load the files as usual:

if (!myFont.loadFromFile ("fonts//asd.ttf"))
// ...
 

And it works fine.
However, under Linux, this doesn´t work. The game compiles fine, but when I run it, I get this error message:

Failed to load font <filename>  (failed to create the font face)

The font files seems to work fine (I can open them from Dolphin, the KDE file explorer)

I tried changing the file path:

I can open (read and write) simple text files created by me using std::fstream. It works. Even files inside a folder (like "./config/engine.cfg")

Am I doing something wrong? Do I need to specify the full path to the files under Linux? SFML bug?
 :-\


EDIT:: Solved
Title: Re: Can´t load Font files under Linux
Post by: Gan on February 25, 2013, 10:33:12 pm
For mac you have to get the resource path and appent the font folder to the resource path.
You might have to do the same for Linux.
Title: Re: Can´t load Font files under Linux
Post by: eXpl0it3r on February 25, 2013, 10:49:16 pm
I'm not quite sure, but why would you use double forward slashes? ???
I mean it makes sense to use double backward slashes, since one backward slash is reserved for excaping stuff (e.g. \t or \n), but for forward slashes, there isn't really a use, not on Windows and not on Linux, maybe you can try it without and see if that works?

Also make sure that it's really relative to the current working directory. Otherwise you might think about installing stuff into the shared directory.

You might have to do the same for Linux.
Not really...
Title: Re: Can´t load Font files under Linux
Post by: vivo on February 26, 2013, 01:35:36 pm
Hi, using linux and rbSFML i do:
@@font = Font.new(Fonts_path.to_s + 'ilits.ttf')
 
I had problems with the loadFromFile method too, try with the constructor as I did
Title: Re: Can´t load Font files under Linux
Post by: CodingMadeEasy on February 27, 2013, 09:43:47 am
Why not try one forward slash instead of 2?
Title: Re: Can´t load Font files under Linux
Post by: mateandmetal on February 28, 2013, 12:38:30 am
Problem solved

The font file extension was .TTF (uppercase)  :-[
I didn't notice until I run ls from the console..  :-[

Btw, the classic path format "./fonts/myfont.ttf" works fine  8)
No absolute path needed

Thanks!  ;)