Skip to main content

Can I display a text in SFML without setting a font?

Well, I wasI'm trying to render a text without setting a font. That's how code looks: #include <SFML/Graphics.hpp> #include using namespace std; string culoare; int main() {

#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
string culoare;
int main()
{

    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        sf::Text text;
            //atext.setFont();
            text.setString("HelloWorld");
            text.setCharacterSize(20);
            text.setStyle(sf::Text::Bold);
            text.setColor(sf::Color::White);
            text.setPosition(0,0);
            window.draw(text);
            window.clear(sf::Color::Green);
            window.display();
    }

    return 0;
}

} This This just make a green window, but doesn't display text.

Can I display a text in SFML without setting a font?

Well, I was trying to render a text without setting font. That's how code looks: #include <SFML/Graphics.hpp> #include using namespace std; string culoare; int main() {

sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
while (window.isOpen())
{
    sf::Event event;
    while (window.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
            window.close();
    }
    sf::Text text;
        //atext.setFont();
        text.setString("HelloWorld");
        text.setCharacterSize(20);
        text.setStyle(sf::Text::Bold);
        text.setColor(sf::Color::White);
        text.setPosition(0,0);
        window.draw(text);
        window.clear(sf::Color::Green);
        window.display();
}

return 0;

} This just make a green window, but doesn't display text.

Can I display text in SFML without setting a font?

I'm trying to render text without setting a font.

#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
string culoare;
int main()
{

    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        sf::Text text;
            //atext.setFont();
            text.setString("HelloWorld");
            text.setCharacterSize(20);
            text.setStyle(sf::Text::Bold);
            text.setColor(sf::Color::White);
            text.setPosition(0,0);
            window.draw(text);
            window.clear(sf::Color::Green);
            window.display();
    }

    return 0;
}

This just make a green window, but doesn't display text.

Source Link
Stucky
  • 1
  • 1
  • 1

Can I display a text in SFML without setting a font?

Well, I was trying to render a text without setting font. That's how code looks: #include <SFML/Graphics.hpp> #include using namespace std; string culoare; int main() {

sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
while (window.isOpen())
{
    sf::Event event;
    while (window.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
            window.close();
    }
    sf::Text text;
        //atext.setFont();
        text.setString("HelloWorld");
        text.setCharacterSize(20);
        text.setStyle(sf::Text::Bold);
        text.setColor(sf::Color::White);
        text.setPosition(0,0);
        window.draw(text);
        window.clear(sf::Color::Green);
        window.display();
}

return 0;

} This just make a green window, but doesn't display text.