加载字体语句
osg::ref_ptr<osgText::Font> g_font = osgText::readFontFile("fonts/arial.ttf");
在不同系统中加载路径是不同的,针对WIN32、Apple、Linux等系统的路径设置为:
osgText/Font.cpp
#if defined(WIN32)
osgDB::convertStringPathIntoFilePathList(
".;C:/winnt/fonts;C:/windows/fonts",
s_FontFilePath);
char *ptr;
if ((ptr = getenv( "windir" )))
{
std::string winFontPath = ptr;
winFontPath += "\\fonts";
s_FontFilePath.push_back(winFontPath);
}
#elif defined(__APPLE__)
osgDB::convertStringPathIntoFilePathList(
".:/usr/share/fonts/ttf:/usr/share/fonts/ttf/western:/usr/share/fonts/ttf/decoratives:/Library/Fonts:/System/Library/Fonts",
s_FontFilePath);
#else
osgDB::convertStringPathIntoFilePathList(
".:/usr/share/fonts/ttf:/usr/share/fonts/ttf/western:/usr/share/fonts/ttf/decoratives",
s_FontFilePath);
#endif