diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp index 786856e408..a071c0ac71 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp @@ -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);