1. fixes TextReader load default font error.

This commit is contained in:
zhangcheng 2014-07-10 19:29:39 +08:00
parent e749a9a598
commit a0ecae21c3
1 changed files with 17 additions and 2 deletions

View File

@ -102,8 +102,23 @@ namespace cocostudio
label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20)); label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20));
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑"); std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑");
std::string fontFilePath = jsonPath.append(fontName); std::string file_extension = ;
label->setFontName(fontFilePath); size_t pos = fontName.find_last_of('.');
if (pos != std::string::npos)
{
file_extension = fontName.substr(pos, fontName.length());
std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper);
}
if(file_extension.compare(".TTF") == 0)
{
std::string fontFilePath = jsonPath.append(fontName);
label->setFontName(fontFilePath);
}
else
{
label->setFontName(fontName);
}
bool aw = DICTOOL->checkObjectExist_json(options, P_AreaWidth); bool aw = DICTOOL->checkObjectExist_json(options, P_AreaWidth);
bool ah = DICTOOL->checkObjectExist_json(options, P_AreaHeight); bool ah = DICTOOL->checkObjectExist_json(options, P_AreaHeight);