SFML在Windows下加载字体时出错 [英] SFML Error loading font under Windows
问题描述
我一直在尝试使用SFML开发适用于Windows和Linux的跨平台应用程序。一切都进行得很好,到目前为止,除了Windows版本似乎不能加载字体。我没有在Linux下的问题。
我做了我的研究,并确保该文件到位,根据我从哪里执行,但sf :: Font :: loadFromFile仍然返回false。
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.
这里是代码:
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?
我使用SFML 2.3,静态链接。
I'm using SFML 2.3, linking statically.
更新:loadFromFile方法不适用于纹理。我可以通过编程方式检查文件是否到位,并且用ifstreams打开它们,但SFML似乎不能访问它们。
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.
推荐答案
p>找到问题,像往常一样我的错误:我使用的库的版本,但我的VS项目是在Debug!
Found the problem, as usual my fault: I was using the release version of the library, but my VS project was in Debug!
这篇关于SFML在Windows下加载字体时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!