Merge pull request #7386 from chengstory/v3_fixesLoaddTTFError

1. fixes TextReader load default font error.
This commit is contained in:
minggo 2014-07-11 13:40:16 +08:00
commit d1d84e0d1f
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));
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑");
std::string fontFilePath = jsonPath.append(fontName);
label->setFontName(fontFilePath);
std::string file_extension = ;
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 ah = DICTOOL->checkObjectExist_json(options, P_AreaHeight);