From 651d877e2802d39c9b5ab81e7137972ba8bab875 Mon Sep 17 00:00:00 2001 From: fusijie Date: Mon, 27 Jul 2015 17:55:32 +0800 Subject: [PATCH] set minimum display length to 1. --- cocos/ui/UIRichText.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index 886a42ad72..868bf7f806 100644 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -283,6 +283,8 @@ void RichText::handleTextRenderer(const std::string& text, const std::string& fo std::string curText = text; size_t stringLength = StringUtils::getCharacterCountInUTF8String(text); int leftLength = stringLength * (1.0f - overstepPercent); + //The minimum cut length is 1, otherwise will cause the infinite loop. + if (0 == leftLength) leftLength = 1; std::string leftWords = Helper::getSubStringOfUTF8String(curText,0,leftLength); std::string cutWords = Helper::getSubStringOfUTF8String(curText, leftLength, stringLength - leftLength); if (leftLength > 0)