diff --git a/cocos/2d/assembler/label/ttfUtils.ts b/cocos/2d/assembler/label/ttfUtils.ts index f30abef07d0..82a78d940db 100644 --- a/cocos/2d/assembler/label/ttfUtils.ts +++ b/cocos/2d/assembler/label/ttfUtils.ts @@ -92,6 +92,7 @@ const Alignment = [ export const ttfUtils = { getAssemblerData () { const sharedLabelData = Label._canvasPool.get(); + sharedLabelData.canvas.width = sharedLabelData.canvas.height = 1; return sharedLabelData; }, diff --git a/cocos/2d/components/rich-text.ts b/cocos/2d/components/rich-text.ts index 20345b28026..099f7e32531 100644 --- a/cocos/2d/components/rich-text.ts +++ b/cocos/2d/components/rich-text.ts @@ -483,6 +483,7 @@ export class RichText extends Component { public onLoad () { this.node.on(NodeEventType.LAYER_CHANGED, this._applyLayer, this); + this.node.on(NodeEventType.ANCHOR_CHANGED, this._updateRichTextPosition, this); } public onEnable () { @@ -502,11 +503,6 @@ export class RichText extends Component { this._activateChildren(false); } - public start () { - this._onTTFLoaded(); - this.node.on(NodeEventType.ANCHOR_CHANGED, this._updateRichTextPosition, this); - } - public onRestore () { if (!EDITOR) { return; @@ -1263,12 +1259,6 @@ export class RichText extends Component { label.lineHeight = this._lineHeight; label.updateRenderData(true); - // Todo: need update context size after this function call - // @ts-expect-error update assembler renderData for richText - const assembler = label._assembler; - if (assembler) { - assembler.updateRenderData(label); - } } protected _applyLayer () {