From 92ddc7e523cf244d8c33e47e9b883c828b98284b Mon Sep 17 00:00:00 2001 From: kasandko <39956359+kasandko@users.noreply.github.com> Date: Thu, 11 Jul 2019 16:00:37 +0200 Subject: [PATCH] Fix error with update line height After movig font atlas `reinit()` (https://github.com/cocos2d/cocos2d-x/pull/19384) there was indused a problem: the first display of text with a outline in the label does not update line height. This is because the atlas `reinit()` does not occur when the outline is activated. In this case, a new atlas will be created, but the line height will not be taken from it, because line height calculate in `updateContent()`. I propose line height calculating to return to the font atlas constructor. --- cocos/2d/CCFontAtlas.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp index 00286da8e199..6256350abd8b 100644 --- a/cocos/2d/CCFontAtlas.cpp +++ b/cocos/2d/CCFontAtlas.cpp @@ -72,6 +72,12 @@ FontAtlas::FontAtlas(Font &theFont) _letterPadding += 2 * FontFreeType::DistanceMapSpread; } + auto outlineSize = _fontFreeType->getOutlineSize(); + if (outlineSize > 0) + { + _lineHeight += 2 * outlineSize; + } + #if CC_ENABLE_CACHE_TEXTURE_DATA auto eventDispatcher = Director::getInstance()->getEventDispatcher(); @@ -96,7 +102,6 @@ void FontAtlas::reinit() auto outlineSize = _fontFreeType->getOutlineSize(); if(outlineSize > 0) { - _lineHeight += 2 * outlineSize; _currentPageDataSize *= 2; }