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