From f46237536f446942d18478355682cf832f9c0aa4 Mon Sep 17 00:00:00 2001 From: SmallMain Date: Fri, 27 Dec 2024 15:44:35 +0800 Subject: [PATCH] Fix the character spacing error in the rendering of Label under Char Mode (#17925) --- cocos2d/core/renderer/utils/label/bmfont.js | 4 ++++ cocos2d/core/renderer/utils/label/letter-font.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/renderer/utils/label/bmfont.js b/cocos2d/core/renderer/utils/label/bmfont.js index 0b91a2745ce..529c2774b2e 100644 --- a/cocos2d/core/renderer/utils/label/bmfont.js +++ b/cocos2d/core/renderer/utils/label/bmfont.js @@ -187,6 +187,10 @@ export default class BmfontAssembler extends Assembler2D { } } + _clearHorizontalKerning() { + _horizontalKernings.length = 0; + } + _multilineTextWrap (nextTokenFunc) { let textLen = _string.length; diff --git a/cocos2d/core/renderer/utils/label/letter-font.js b/cocos2d/core/renderer/utils/label/letter-font.js index 5e46af03649..a0f26abcb4c 100644 --- a/cocos2d/core/renderer/utils/label/letter-font.js +++ b/cocos2d/core/renderer/utils/label/letter-font.js @@ -306,7 +306,11 @@ export default class LetterFontAssembler extends WebglBmfontAssembler { return fontDesc; } - _computeHorizontalKerningForText () {} + + _computeHorizontalKerningForText () { + this._clearHorizontalKerning(); + } + _determineRect (tempRect) { return false; }