diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 0b6f9d132452..d0c7cb46789d 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -1876,16 +1876,22 @@ void Label::updateDisplayedColor(const Color3B& parentColor) { Node::updateDisplayedColor(parentColor); + if (_currentLabelType == LabelType::TTF || _currentLabelType == LabelType::STRING_TEXTURE) + setTextColor(Color4B(_displayedColor)); + if (_textSprite) { _textSprite->updateDisplayedColor(_displayedColor); - if (_shadowNode) - { - _shadowNode->updateDisplayedColor(_displayedColor); - } + } - if (_underlineNode) - _contentDirty = true; + if (_shadowNode) + { + _shadowNode->updateDisplayedColor(_displayedColor); + } + + if (_underlineNode) + { + _contentDirty = true; } for (auto&& it : _letters) diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index c7bb4c1677b0..92bfb02673fe 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -106,6 +106,8 @@ NewLabelTests::NewLabelTests() ADD_TEST_CASE(LabelBold); ADD_TEST_CASE(LabelLocalizationTest); + + ADD_TEST_CASE(LabelIssue15214); }; LabelFNTColorAndOpacity::LabelFNTColorAndOpacity() @@ -3149,3 +3151,29 @@ void LabelLocalizationTest::onChangedRadioButtonSelect(RadioButton* radioButton, break; } } + +// LabelBMFontBinaryFormat +LabelIssue15214::LabelIssue15214() +{ + auto size = Director::getInstance()->getVisibleSize(); + Label* label = Label::createWithTTF("CHECK!", "fonts/arial.ttf", 48.0f); + label->enableUnderline(); + label->setColor(cocos2d::Color3B::BLUE); + label->setPosition(size.width/2, size.height/3*2); + this->addChild(label); + label = Label::createWithSystemFont("CHECK!", "Verdana", 48.0f); + label->enableUnderline(); + label->setColor(cocos2d::Color3B::BLUE); + label->setPosition(size.width/2, size.height/3*1); + this->addChild(label); +} + +std::string LabelIssue15214::title() const +{ + return "Githug Issue 15214"; +} + +std::string LabelIssue15214::subtitle() const +{ + return "Font and underline should be of the same color"; +} diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h index c6708a129207..0818eb311c77 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h @@ -850,4 +850,14 @@ class LabelLocalizationTest : public AtlasDemoNew cocostudio::ILocalizationManager* _localizationBin; }; +class LabelIssue15214 : public AtlasDemoNew +{ +public: + CREATE_FUNC(LabelIssue15214); + + LabelIssue15214(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; #endif