SFML community forums

Help => Graphics => Topic started by: BeautiCode on June 28, 2014, 07:58:16 am

Title: Weird sf::Font error
Post by: BeautiCode on June 28, 2014, 07:58:16 am
   
sf::Font font;
font.loadFromFile("C:\\Windows\\Fonts\\Arial.ttf");

I always get this weird error when trying to load a font from a file.
"Error: 'font' does not name a type

Can someone help me figure out the problem?
I have Graphics.hpp included, and everything linked.
Title: Re: Weird sf::Font error
Post by: Nexus on June 28, 2014, 10:10:50 am
Please read this (http://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368) and adapt your question correspondingly.
Title: Re: Weird sf::Font error
Post by: Jesper Juhl on June 28, 2014, 05:24:00 pm
sf::Font is defined in "Font.hpp" - http://sfml-dev.org/documentation/2.1/classsf_1_1Font.php
Title: Re: Weird sf::Font error
Post by: BeautiCode on June 29, 2014, 02:05:00 am
Apparently the problem was that I was trying to do loadFromFile() inside the class declaration, in the beginning of my .h file
It works fine when I do it inside a function.