From 8b254fb84d176552302b8bfa2ff80eaeb3a06dbf Mon Sep 17 00:00:00 2001 From: SmallMain Date: Wed, 27 Nov 2024 15:42:51 +0800 Subject: [PATCH] [engine] Fix the character spacing error in the rendering of Label under Char Mode --- engine/cocos2d/core/renderer/utils/label/bmfont.js | 4 ++++ engine/cocos2d/core/renderer/utils/label/letter-font.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/engine/cocos2d/core/renderer/utils/label/bmfont.js b/engine/cocos2d/core/renderer/utils/label/bmfont.js index ccce272b..c4e8b4cf 100644 --- a/engine/cocos2d/core/renderer/utils/label/bmfont.js +++ b/engine/cocos2d/core/renderer/utils/label/bmfont.js @@ -232,6 +232,10 @@ export default class BmfontAssembler extends Assembler2D { } } + _clearHorizontalKerning() { + _horizontalKernings.length = 0; + } + _multilineTextWrap (nextTokenFunc) { let textLen = _string.length; diff --git a/engine/cocos2d/core/renderer/utils/label/letter-font.js b/engine/cocos2d/core/renderer/utils/label/letter-font.js index b90534e3..9b815ce7 100644 --- a/engine/cocos2d/core/renderer/utils/label/letter-font.js +++ b/engine/cocos2d/core/renderer/utils/label/letter-font.js @@ -560,7 +560,11 @@ export default class LetterFontAssembler extends WebglBmfontAssembler { return fontDesc; } - _computeHorizontalKerningForText () {} + + _computeHorizontalKerningForText () { + this._clearHorizontalKerning(); + } + _determineRect (tempRect) { return false; }