From ed55d41858a47295bef1c1854c5f9f2b9db4681c Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Wed, 2 Dec 2015 13:48:20 +0800 Subject: [PATCH] fix label clamp when scaled with bmfont --- cocos/2d/CCLabel.cpp | 4 ++-- cocos/2d/CCLabelTextFormatter.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index ede619ef3a..4d90072e29 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -840,14 +840,14 @@ bool Label::updateQuads() _reusedRect.size.height -= clipTop; py -= clipTop; } - if (py - letterDef.height < _tailoredBottomY) + if (py - letterDef.height * _bmfontScale < _tailoredBottomY) { _reusedRect.size.height = (py < _tailoredBottomY) ? 0.f : (py - _tailoredBottomY); } } if(!_enableWrap){ - auto px = _lettersInfo[ctr].positionX + letterDef.width/2 + _linesOffsetX[_lettersInfo[ctr].lineIndex]; + auto px = _lettersInfo[ctr].positionX + letterDef.width/2 * _bmfontScale + _linesOffsetX[_lettersInfo[ctr].lineIndex]; if(_labelWidth > 0.f){ if (px > _contentSize.width || px < 0) { if(_overflow == Overflow::CLAMP){ diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 9454b39e46..00cbbbe7f0 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -267,7 +267,7 @@ bool Label::isHorizontalClamp() { auto& letterDef = _fontAtlas->_letterDefinitions[_lettersInfo[ctr].utf16Char]; - auto px = _lettersInfo[ctr].positionX + letterDef.width/2; + auto px = _lettersInfo[ctr].positionX + letterDef.width/2 * _bmfontScale; if(_labelWidth > 0.f){ if (px > _contentSize.width) { letterClamp = true;