As Laurent said, you should load the font outside of the game loop. In your code, the font is loaded many times per second and it totally unnecessary
Also check if the "font.ttf" is in the same folder as your .exe file. Does this work?
#include <string>
#include <sstream>
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Test", sf::Style::Default);
sf::Font font;
if (!font.loadFromFile("font.ttf"))
{
std::cerr << "error";
}
int number = 1000;
std::ostringstream oss;
oss << number;
sf::Text text;
text.setFont(font);
text.setString(oss.str());
text.setColor(sf::Color::Red);
text.setPosition(400, 300);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(text);
window.display();
}
return 0;
}