SDL C++ IDE 无法打开.ttf文件
SDL C++ IDE can't open .ttf file
我将ttf文件包含在我的项目中,我将这个ttf复制到调试文件夹和System32文件夹中,然后将其安装在Windows上。我使用了在互联网上找到的另一个C++来源,它也不能正常工作。但是如果我直接从"调试"(而不是从 IDE)文件夹运行二进制文件,它可以正常工作。
我正在使用CodeBlocks,SDL2。
代码
中使用的路径相对于运行应用的目录。
如果.ttf文件与应用程序位于同一目录中,则应使用SDL_GetBasePath()
来确定其位置:
char* p = SDL_GetBasePath();
if(p == nullptr) { /* TODO: error */ }
std::string ttfPath = std::string(p) + "myfont.ttf";
SDL_free(p); // TODO: exception safety
// now, you can open the file
TTF_Font* f = TTF_OpenFont(ttfPath.c_str(), 42);
// ...
相关文章:
- .cpp和.h文件中的模板专用化声明
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 文本文件中的单词链表
- CMake-按正确顺序将项目与C运行时对象文件链接
- 使用新行和不使用新行读取文件
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 挂起和取消挂起一个文件DLL
- 如何确定我已使用非编码文件到达 EOF?
- 命名空间中具有.h和.cpp文件的类
- 如何使用ndk-build.cmd构建Android.so文件
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 读取文件并输入到矢量中
- 在C++中查找文件
- c++库的公共头文件中应该包含什么
- 用c++从输入文件中读取另一行
- Cppcheck生成xml转储文件
- 嵌入式软件中的TTF/OTF文件类型
- 当我从 Windows 请求"Miriam"字体时,我得到的是"Arial"字体。这怎么可能,因为字体文件"mriam.ttf"存在于我的系统中?
- SDL C++ IDE 无法打开.ttf文件
- 无法使用libzip和FreeType直接从ZIP加载TTF文件