set minimum display length to 1.

This commit is contained in:
fusijie 2015-07-27 17:55:32 +08:00
parent 3fb45f28f5
commit 651d877e28
1 changed files with 2 additions and 0 deletions

View File

@ -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)