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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - TopMux

Pages: [1]
1
General / Re: Problem with fonts
« on: August 02, 2024, 10:05:34 pm »
Thanks for this answer. It finally worked!

2
General / Re: Problem with fonts
« on: July 25, 2024, 08:15:37 pm »
I copied arial.ttf to all project folders.

3
General / Problem with fonts
« on: July 25, 2024, 05:17:09 pm »
I'm just starting to learn SFML so I don't understand why this code isn't working. As I understand it, the font simply cannot be loaded, which is why the error occurs. I tried everything I could, absolute path, different fonts, different paths, ran as administrator.
Error:
Failed to load font "AtЇE"
arial.ttf HїO╓▓█ПьУ·┤╟Ў∙FфT}ь< ─Ў∙" (failed to create the font face).
Here is the code:
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Text");

    sf::Font font;
    if (!font.loadFromFile("arial.ttf")) {
        return EXIT_FAILURE;
    }

    sf::Text text("Hello, SFML!", font, 30);
    text.setFillColor(sf::Color::White);
    text.setPosition(200, 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 EXIT_SUCCESS;
}
 
Some additional information: I'm working in Visual Studio 2022 and my operating system is Windows 11


Pages: [1]
anything