SFML community forums

Help => General => Topic started by: groenewoldr on September 18, 2015, 02:02:30 am

Title: Font problems
Post by: groenewoldr 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?
Title: Re: Font problems
Post by: G. 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?
Title: Re: Font problems
Post by: Hapax 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"?