cocos2dx wp8 下字体显示
最近在把游戏移植到wp8上
代码基本跑起来了发现文字都显示不出来
跟踪代码发现wp8下CCFreeTypeFont查找字体的代码
unsigned char* CCFreeTypeFont::loadFont(const char *pFontName, unsigned long *size)
{
std::string lowerCase(pFontName);
std::string path(pFontName);
for (unsigned int i = 0; i < lowerCase.length(); ++i)
{
lowerCase[i] = tolower(lowerCase[i]);
}
if (std::string::npos == lowerCase.find("fonts/"))
{
path = "fonts/";
path += pFontName;
}
if (std::string::npos == lowerCase.find(".ttf"))
{
path += ".ttf";
}
std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathForFilename(path.c_str());
return CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", size);
}
要把字体放在Resources/fonts目录下
另外
unsigned char* CCFreeTypeFont::loadSystemFont(const char *pFontName, unsigned long *size)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
return nullptr;
#else
wp8是加载不了系统字体的,也就是说如果字体不存在或未指定就显示不出任何字,这个和android和ios还不一样。。。

浙公网安备 33010602011771号