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

Author Topic: Font problems  (Read 843 times)

0 Members and 1 Guest are viewing this topic.

groenewoldr

  • Newbie
  • *
  • Posts: 1
    • View Profile
Font problems
« on: September 18, 2015, 02:02:30 am »
sf::RenderWindow window(sf::VideoMode(800, 600), "CALENDAR");

sf::Font font;
if (!font.loadFromFile("arial.ttf"))
    std::cout << "no\n";

sf::Text text1;
text1.setFont(font);
text1.setCharacterSize(30);
text1.setColor(sf::Color::Black);
text1.setStyle(sf::Text::Regular);
text1.setString("ttestst");

while (window.isOpen())
{
    sf::Event event;
    while (window.pollEvent(event))
    {
        switch (event.type){
        case sf::Event::Closed:
            window.close();
        }
    }

    window.clear(sf::Color::White);
    window.draw(text1);
    window.display();
}


I'm pretty sure this should work, but for whatever reason, it doesn't import the font correctly, can anyone help?

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: Font problems
« Reply #1 on: September 18, 2015, 04:17:24 am »
What's wrong, any error? How do you know the font isn't imported correctly?
Can you cout std::endl (or flush) with your "no\n"? If you don't flush your stream it may not (or won't?) print its content until its buffer is full.
Where is arial.ttf located?

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Font problems
« Reply #2 on: September 20, 2015, 10:36:59 pm »
If the font fails to load for any reason, the application still continues.

Is the application outputting "no"?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*