Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML 2.0 Font Load Bug?  (Read 5142 times)

0 Members and 1 Guest are viewing this topic.

MetalCoder

  • Newbie
  • *
  • Posts: 31
    • View Profile
SFML 2.0 Font Load Bug?
« on: May 04, 2013, 10:01:43 pm »
Hello,

I am having trouble whenver I try to load a font. When I goto load the font, the program shows a bunch of text in the console window, then crashes. However when I compile it without a font, it builds and runs normally.

game.h
        Font GameFont;

game.cpp
        if(!GameFont.loadFromFile("sansation.ttf"))
        {
                exit(EXIT_FAILURE);
        }

Not sure what the problem. Sorry if I posted in the wrong section. I'm using SFML 2.0, Visual Studio 2012 Express. Windows 7 64-bit Ultimate. Nvidia Graphics card 8600M GT. It says the program exits with a code of 0x1

Raphman

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Email
Re: SFML 2.0 Font Load Bug?
« Reply #1 on: May 04, 2013, 11:27:21 pm »
is that font file in the same directory as your sln?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10879
    • View Profile
    • development blog
    • Email
Re: SFML 2.0 Font Load Bug?
« Reply #2 on: May 04, 2013, 11:28:36 pm »
the program shows a bunch of text in the console window
Don't you think, that this "bunch" of text could be useful/important? ::)

You should never use exit(), since this will exit the application uncleanly, which might lead to crashes.

I'd guess that the font doesn't get loaded properly.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MetalCoder

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: SFML 2.0 Font Load Bug?
« Reply #3 on: May 05, 2013, 12:01:33 am »
It says failed to load font "sansation.ttf" (failed to create the font face). I have the font in the .exe directory of the project. Do I need the full path for it to find the font file?

Raphman

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Email
Re: SFML 2.0 Font Load Bug?
« Reply #4 on: May 05, 2013, 12:28:08 am »
Well, when I load my font files, I do use a relative path from the .exe. you could try doing "./sansation.ttf".

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10879
    • View Profile
    • development blog
    • Email
Re: SFML 2.0 Font Load Bug?
« Reply #5 on: May 05, 2013, 12:41:17 am »
I have the font in the .exe directory of the project.
The exe will search for the TTF in the working directory, which in VS is by default where the project file is located. So put your font next to your project file and it should get loaded.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Raphman

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Email
Re: SFML 2.0 Font Load Bug?
« Reply #6 on: May 05, 2013, 12:49:29 am »
Or you could set the working directory to your .exe directory, but yeah, doing what eXpl0it3er said is a better solution.

Also I meant project, not sln. I do that all the time ><;
« Last Edit: May 05, 2013, 12:51:15 am by Raphman »

MetalCoder

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: SFML 2.0 Font Load Bug?
« Reply #7 on: May 05, 2013, 12:50:02 am »
Thanks for the help. I moved it into the Project folder, and now it works.