SFML community forums
Help => General => Topic started 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?
-
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?
-
If the font fails to load for any reason, the application still continues.
Is the application outputting "no"?