SFML Error loading font under Windows

和自甴很熟 提交于 2019-12-01 13:30:39

问题


I've been trying to develop a cross-platform application for Windows and Linux using SFML. Everything's been going fine so far, except that the Windows version cannot seem to load fonts. I have no issues under Linux however. I did my research and made sure the file was in place, according to where I was executing from, but sf::Font::loadFromFile still returns false.

Here's the code:

sf::Font _font;
sf::Text _text;

if (!(_font.loadFromFile("resources/fonts/arial.ttf")))
{
    std::cerr << "Error loading font '" + font + "'" << std::endl;
    return;
}
_text.setFont(_font);

Do you guys have any idea what I'm doing wrong here?

I'm using SFML 2.3, linking statically.

Update: the loadFromFile methods doesn't work either for textures. I can check programmatically that the files are in place, and opening them with ifstreams works fine, but SFML cannot seem to access them.


回答1:


Found the problem, as usual my fault: I was using the release version of the library, but my VS project was in Debug!




回答2:


Check to make sure your file is in the correct directory and make sure the spelling is exact as well. Usually this is the most common source of error.



来源:https://stackoverflow.com/questions/34432079/sfml-error-loading-font-under-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!