1
我已经noodling周围的SDL和OpenGL(在C++),并决定得到一些文字到我的比赛。SDL_ttf - 字体目录/字体在哪里去?
我跟着几个教程,但我总是得到同样的错误:“无法找到.ttf”我确信它之前已被问过,但你应该在哪里放置字体,你应该写什么在TTF_OpenFont的第一个参数?这是迄今为止的TTF部分。
if (TTF_Init() != 0)
{
cerr << "TTF_Init() Failed: " << TTF_GetError() << endl;
SDL_Quit();
exit(1);
}
TTF_Font *font;
font = TTF_OpenFont("FreeSans.ttf", 24);
if (font == NULL)
{
cerr << "TTF_OpenFont() Failed: " << TTF_GetError() << endl; // <-- This the error report
TTF_Quit();
SDL_Quit();
exit(1);
}
SDL_Surface *text;
SDL_Color text_color = {255, 255, 255};
text = TTF_RenderText_Solid(font, "BLAH, BLAH, BLAH!", text_color);
好。 Mac上的路径是什么?我都尝试的“Macintosh HD/FreeSans.ttf”和“用户/姓名/ FreeSans.ttf”,既在各自的点的文件,既不工作。 – 2013-02-28 21:29:47
http://www.westwind.com/reference/os-x/paths.html – 2013-02-28 21:33:59
第一次我把它写入磁盘本身(而不是在任何文件夹),所以“的Macintosh HD/FreeSans.ttf”。 – 2013-02-28 21:34:41