Skip to content

Commit

Permalink
Merge pull request #15882 from ricardoquesada/issue15214
Browse files Browse the repository at this point in the history
fix: underline will have the same solor as text in TTF
  • Loading branch information
ricardoquesada committed Jun 18, 2016
2 parents d9b3ef5 + 3500870 commit 49e24eb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
18 changes: 12 additions & 6 deletions cocos/2d/CCLabel.cpp
Expand Up @@ -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)
Expand Down
28 changes: 28 additions & 0 deletions tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp
Expand Up @@ -106,6 +106,8 @@ NewLabelTests::NewLabelTests()
ADD_TEST_CASE(LabelBold);

ADD_TEST_CASE(LabelLocalizationTest);

ADD_TEST_CASE(LabelIssue15214);
};

LabelFNTColorAndOpacity::LabelFNTColorAndOpacity()
Expand Down Expand Up @@ -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";
}
10 changes: 10 additions & 0 deletions tests/cpp-tests/Classes/LabelTest/LabelTestNew.h
Expand Up @@ -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

0 comments on commit 49e24eb

Please sign in to comment.