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

Author Topic: Weird sf::Font error  (Read 1902 times)

0 Members and 3 Guests are viewing this topic.

BeautiCode

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Weird sf::Font error
« 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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Weird sf::Font error
« Reply #1 on: June 28, 2014, 10:10:50 am »
Please read this and adapt your question correspondingly.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Weird sf::Font error
« Reply #2 on: June 28, 2014, 05:24:00 pm »

BeautiCode

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Weird sf::Font error
« Reply #3 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.

 

anything