From 1d6bdc5c3612515bcab900c485c8c9d9ff8803fa Mon Sep 17 00:00:00 2001 From: knoxHuang <821686174@qq.com> Date: Mon, 4 Dec 2017 16:19:21 +0800 Subject: [PATCH] fix label warp bug for cocos-creator/engine/issues/2151 --- cocos2d/core/label/CCTextUtils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/label/CCTextUtils.js b/cocos2d/core/label/CCTextUtils.js index 1253f43ce7..26c1621340 100644 --- a/cocos2d/core/label/CCTextUtils.js +++ b/cocos2d/core/label/CCTextUtils.js @@ -296,12 +296,14 @@ var TextUtils = { sText = text.substr(0, fuzzyLen); } } - if (sText.trim().length > 0) { + sText = sText.trim(); + if (sText.length > 0) { wrappedWords.push(sText); } text = sLine || tmpText; allWidth = measureText(text); } + text = text.trim(); if (text.length > 0) { wrappedWords.push(text); }