From a0ecae21c34cd83b629d64dfe725ffee1a7d5403 Mon Sep 17 00:00:00 2001 From: zhangcheng Date: Thu, 10 Jul 2014 19:29:39 +0800 Subject: [PATCH] 1. fixes TextReader load default font error. --- .../WidgetReader/TextReader/TextReader.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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);