Skip to content

Commit 831ca47

Browse files
committed
Merge pull request #12158 from WenhaiLin/v3-letter-space
Label:Fixed letter spacing may be wrong.
2 parents 111420e + ffa7dc6 commit 831ca47

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cocos/2d/CCLabelTextFormatter.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
407407
}
408408
}
409409

410-
letterPosition.x = (nextFontPositionX + charXOffset + kernings[i]) / contentScaleFactor;
410+
letterPosition.x = (nextFontPositionX + charXOffset) / contentScaleFactor;
411411
letterPosition.y = (nextFontPositionY - charYOffset) / contentScaleFactor;
412412

413413
if( theLabel->recordLetterInfo(letterPosition, tempDefinition, i) == false)
@@ -417,6 +417,10 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
417417
}
418418

419419
nextFontPositionX += charAdvance + theLabel->_additionalKerning;
420+
if (i < stringLen - 1)
421+
{
422+
nextFontPositionX += kernings[i + 1];
423+
}
420424

421425
auto letterRight = letterPosition.x + tempDefinition.width;
422426
if (longestLine < letterRight)

0 commit comments

Comments
 (0)