Merge pull request #12386 from WenhaiLin/v3-label-spacefix

Label:Fixed wrong letter spacing with outline enabled
This commit is contained in:
pandamicro 2015-06-17 15:16:49 +08:00
commit 6f6c317f87
2 changed files with 30 additions and 14 deletions

View File

@ -343,7 +343,6 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
}
}
xAdvance += 2 * _outlineSize;
outRect.size.width = blendWidth;
outRect.size.height = blendHeight;
outWidth = blendWidth;

View File

@ -955,24 +955,41 @@ void Label::onDraw(const Mat4& transform, bool transformUpdated)
}
}
if (_currentLabelType == LabelType::TTF)
{
glprogram->setUniformLocationWith4f(_uniformTextColor,
_textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a);
if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW)
{
glprogram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
}
}
glprogram->setUniformsForBuiltins(transform);
for(const auto &child: _children)
{
child->updateTransform();
}
if (_currentLabelType == LabelType::TTF)
{
switch (_currLabelEffect) {
case LabelEffect::OUTLINE:
//draw text with outline
glprogram->setUniformLocationWith4f(_uniformTextColor,
_textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a);
glprogram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
for (const auto& batchNode:_batchNodes)
{
batchNode->getTextureAtlas()->drawQuads();
}
//draw text without outline
glprogram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r, _effectColorF.g, _effectColorF.b, 0.f);
break;
case LabelEffect::GLOW:
glprogram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
case LabelEffect::NORMAL:
glprogram->setUniformLocationWith4f(_uniformTextColor,
_textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a);
break;
default:
break;
}
}
for (const auto& batchNode:_batchNodes)
{