SFML community forums
Help => General => Topic started by: BeautiCode on June 20, 2014, 09:36:06 pm
-
So I was learning basic SFML from the tutorials page, since I'm new to this.
But tutorials like this (http://www.sfml-dev.org/tutorials/2.1/graphics-text.php) one tell me to call loadFromFile("font.tff"); or whatever, but they don't tell me where to get the font file or anything. therefore, some of the code ends up being invalid. Can someone help me find the files they refer to?
Even on the sprite tutorial, they aren't elaborate.
-
SFML doesn't provide any font, you have to use whatever font you want to.
Same goes for sprites, use any image you want to.
-
The tutorials try to be generic so they will work for everyone. You may have to grab a few resources from other sources yourself.
-
Is there any default font or something? Do I HAVE to download a font somewhere in order to draw text on the screen?
-
Download one (Google "free font"). Or grab one from your system font directory. Fonts are really not hard to find.
And yes, you have to use a font to draw text. Like every other program that draws text does -- even notepad.
-
What does this mean?
(http://i.imgur.com/oNdlwtF.png)
Heres the code
(http://i.imgur.com/56PqktB.png)
-
That means what it says: it couldn't load the font. 90% of the time that's because the file doesn't exist or you gave it the wrong filepath.
I notice you wrote tff instead of ttf. Maybe that's it.
-
Or maybe it's the common mistake of thinking that your cwd (current working directory) is something fixed. It's not magic, but for each OS you need to know the rules - and when running through some IDE the CWD is often different.
And seriously. If you can't go grab a simple font from somewhere (even the OS you are already running). Then how the hell are you going to solve other problems?? This is trivial stuff - just go grab a font file somewhere for crying out loud.
Edit: yes I'm being a dick - sorry. I'm just fed up with trivial questions that could be solved with a little bit of research. I'll shut up now.
-
Ixrec's solution worked, thanks!
And alriight, I'll grab a font from somewhere else next time.
-
Or maybe it's the common mistake of thinking that your cwd (current working directory) is something fixed. It's not magic, but for each OS you need to know the rules - and when running through some IDE the CWD is often different.
That's out of topic, since he's using an absolute path.