简体   繁体   English

SFML错误在Windows下加载字体

[英]SFML Error loading font under Windows

I've been trying to develop a cross-platform application for Windows and Linux using SFML. 我一直在尝试使用SFML为Windows和Linux开发跨平台应用程序。 Everything's been going fine so far, except that the Windows version cannot seem to load fonts. 到目前为止,一切都进行得很好,除了Windows版本似乎无法加载字体。 I have no issues under Linux however. 在Linux下,我没有任何问题。 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. 我做了研究,并根据我从哪里执行文件,确定文件在适当的位置,但是sf :: Font :: loadFromFile仍然返回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. 我正在使用SFML 2.3,静态链接。

Update: the loadFromFile methods doesn't work either for textures. 更新:loadFromFile方法对纹理也不起作用。 I can check programmatically that the files are in place, and opening them with ifstreams works fine, but SFML cannot seem to access them. 我可以通过编程方式检查文件是否到位,并使用ifstreams打开它们可以正常工作,但是SFML似乎无法访问它们。

像往常一样发现了问题,这是我的错:我正在使用库的发行版,但是我的VS项目在Debug中!

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. 通常,这是最常见的错误来源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM