Skip to content

Commit f0cdd02

Browse files
kasandkominggo
authored andcommitted
Fix error with update line height (#19914)
After movig font atlas `reinit()` (#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.
1 parent efb2d7c commit f0cdd02

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: cocos/2d/CCFontAtlas.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ FontAtlas::FontAtlas(Font &theFont)
7272
_letterPadding += 2 * FontFreeType::DistanceMapSpread;
7373
}
7474

75+
auto outlineSize = _fontFreeType->getOutlineSize();
76+
if (outlineSize > 0)
77+
{
78+
_lineHeight += 2 * outlineSize;
79+
}
80+
7581
#if CC_ENABLE_CACHE_TEXTURE_DATA
7682
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
7783

@@ -96,7 +102,6 @@ void FontAtlas::reinit()
96102
auto outlineSize = _fontFreeType->getOutlineSize();
97103
if(outlineSize > 0)
98104
{
99-
_lineHeight += 2 * outlineSize;
100105
_currentPageDataSize *= 2;
101106
}
102107

0 commit comments

Comments
 (0)