diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index db32fa085f..f8eb51e1df 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -476,7 +476,6 @@ void Label::setString(const std::string& text) std::u16string utf16String; if (StringUtils::UTF8ToUTF16(_originalUTF8String, utf16String)) { - _originalUTF16String = utf16String; _currentUTF16String = utf16String; } } @@ -927,10 +926,16 @@ void Label::setFontDefinition(const FontDefinition& textDefinition) void Label::updateContent() { + std::u16string utf16String; + if (StringUtils::UTF8ToUTF16(_originalUTF8String, utf16String)) + { + _currentUTF16String = utf16String; + } + computeStringNumLines(); if (_fontAtlas) { - computeHorizontalKernings(_originalUTF16String); + computeHorizontalKernings(_currentUTF16String); } if (_textSprite) diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index eaffb636e1..f8c7a1ab77 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -344,7 +344,6 @@ protected: int _currNumLines; std::u16string _currentUTF16String; - std::u16string _originalUTF16String; std::string _originalUTF8String; float _fontScale; diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 6a0a7aed63..9dfd813039 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -173,9 +173,9 @@ bool LabelTextFormatter::multilineText(Label *theLabel) std::u16string strNew(multiline_string.begin(), multiline_string.end()); - theLabel->_originalUTF16String = strNew; + theLabel->_currentUTF16String = strNew; theLabel->computeStringNumLines(); - theLabel->computeHorizontalKernings(theLabel->_originalUTF16String); + theLabel->computeHorizontalKernings(theLabel->_currentUTF16String); return true; }