underline and strikethrough working ok on system fonts

This commit is contained in:
Ricardo Quesada 2016-01-20 18:41:59 -08:00
parent 7735a75651
commit 60d273e31b
1 changed files with 28 additions and 8 deletions

View File

@ -1382,11 +1382,14 @@ void Label::updateContent()
if (_underlineNode)
{
const float charheight = (_textDesiredHeight / _numberOfLines);
_underlineNode->clear();
if (_numberOfLines)
{
const float charheight = (_textDesiredHeight / _numberOfLines);
_underlineNode->setLineWidth(charheight/6);
// atlas font
for (int i=0; i<_numberOfLines; ++i)
{
float offsety = 0;
@ -1397,6 +1400,20 @@ void Label::updateContent()
_underlineNode->drawLine(Vec2(_linesOffsetX[i],y), Vec2(_linesWidth[i] + _linesOffsetX[i],y), _textColorF);
}
}
else if (_textSprite)
{
// system font
float y = 0;
const auto spriteSize = _textSprite->getContentSize();
_underlineNode->setLineWidth(spriteSize.height/6);
if (_strikethroughEnabled)
// FIXME: system fonts don't report the height of the font correctly. only the size of the texture, which is POT
y += spriteSize.height / 2;
// FIXME: Might not work with different vertical alignments
_underlineNode->drawLine(Vec2(0,y), Vec2(spriteSize.width,y), Color4F(_textSprite->getDisplayedColor()));
}
}
if(updateFinished){
_contentDirty = false;
@ -1857,6 +1874,9 @@ void Label::updateDisplayedColor(const Color3B& parentColor)
{
_shadowNode->updateDisplayedColor(_displayedColor);
}
if (_underlineNode)
_contentDirty = true;
}
for (auto&& it : _letters)