Error - Failed to load font

Started by FarFarAway, 02 June 2015, 15:29:11

FarFarAway

Hi!
I am new to TGI and SFML and was happy to succesfully link and bind both libraries.
I worked through some SFML tutorials and then while trying out TGUI stumbled upon an error in the first tutorial (https://tgui.eu/tutorials/v06/intro1/).

Setup:
Windows 7 Sp 1 64 Bit
Code::Blocks 13.12
TDM-GCC Compiler Suite for Windows  4.6 & 4.7 Series Standard MinGW 32-bit Edition
SFML-2.3-windows-gcc-4.7.1-tdm-32-bit
TGUI-0.6.8 MinGW 4.7 TDM (SJLJ) - 32bit

I can build the example code (see link above) without errors, on runtime though, I only receive a black and empty window(as called by the code) and an error message in the cmd-window saying: Failed to load font "TGUI/fonts/DejaVuSans.ttf" (failed to create the font face).

I verified that the file is present and my global variable in code blocks points to the right directory.
Switching from
gui.setGlobalFont("TGUI/fonts/DejaVuSans.ttf");
to
gui.setGlobalFont("fullpath/fonts/DejaVuSans.ttf");
has not helped.

Searching this forum I have not found any suggestions how to fix the problem.

Thank you for your help in advance!
FarFarAway

texus

There is nothing wrong with the function, so if it doesn't find it then it is just not there.
You should try putting the font directly next to your project file or perhaps next to the executable and try with
Code (cpp) Select
gui.setGlobalFont("DejaVuSans.ttf");

If you can't get it to work then post the exact code that you are using.

FarFarAway

Thanks for the quick help.

Putting the font in projects directory (next to project file) fixed the problem. I'll have a look into the path problem sometime in the future.
For now I am happy to work and experiment with the framework.

Keep up the good work! :-)

FarFarAway

P.s. Guess the thread can be marked as "solved".