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

Author Topic: Not understanding font class?  (Read 1386 times)

0 Members and 1 Guest are viewing this topic.

AndreeU17

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Not understanding font class?
« on: May 21, 2014, 12:17:59 am »
Im trying to set text to display on the window however the font never seems to work. I've downloaded numerous of font styles but i'm not sure were to put it inside my project folder as well as how do i label its directory in font.loadfromfile("how does it go here");

Any explanation would be nice, i just want a default font to be able to work with my text, obviously i'd like to use a font but as of right now i just need the text to appear! Thanks

(Not appear as in draw since i can do that, just in making the font work)

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Not understanding font class?
« Reply #1 on: May 21, 2014, 12:23:51 am »
The string you pass to loadFromFile (for any kind of resource) should be a relative filepath, which will be interpreted relative to the current working directory.  Typically, the working directory is the same one the executable is in, so try that first.  If that doesn't work, your IDE is probably doing something annoying, so google for information on what it does.

Incidentally, this is not unique to anything in SFML.  The same rules apply for standard C++ file streams, and pretty much any other library in any other programming language.  So if you're not familiar with terms like "relative filepath", do some googling.
« Last Edit: May 21, 2014, 12:29:51 am by Ixrec »

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Not understanding font class?
« Reply #2 on: May 21, 2014, 12:29:19 am »
Have you read the text inside the first red box of the text & font tutorial?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Not understanding font class?
« Reply #3 on: May 23, 2014, 05:47:40 pm »
If you have doubts about what the cwd (current working directory) is when you execute your program, then why not simply have it print out the result of a call to getcwd() at startup?