From 58f1d4ac9b4cc578fca259c3dd88d95c32951db6 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 6 Sep 2016 11:19:55 +0800 Subject: [PATCH] fix wrap edge cases --- cocos2d/core/components/CCRichText.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/components/CCRichText.js b/cocos2d/core/components/CCRichText.js index 443f1baa1d..60e9337173 100644 --- a/cocos2d/core/components/CCRichText.js +++ b/cocos2d/core/components/CCRichText.js @@ -356,12 +356,12 @@ var RichText = cc.Class({ if (this._lineOffsetX > 0 && fragmentWidth + this._lineOffsetX > this.maxWidth) { //concat previous line var checkStartIndex = 0; - while (this._lineOffsetX < this.maxWidth) { + while (this._lineOffsetX <= this.maxWidth) { var checkEndIndex = this._getFirstWordLen(labelString, checkStartIndex, labelString.length); var checkString = labelString.substr(checkStartIndex, checkEndIndex); var checkStringWidth = this._measureText(checkString, styleIndex); - if(this._lineOffsetX + checkStringWidth < this.maxWidth) { + if(this._lineOffsetX + checkStringWidth <= this.maxWidth) { this._lineOffsetX += checkStringWidth; checkStartIndex += checkEndIndex; } else {