cocos-engine icon indicating copy to clipboard operation
cocos-engine copied to clipboard

Optimize LabelComponent

Open yanjifa opened this issue 6 months ago • 2 comments

Re: #

Changelog

  • en: cc.Label._actualFontSize does not need to be serialized, as it will be calculated in real-time during actual rendering.
  • zh: cc.Label._actualFontSize 没有必要序列化,实际渲染时会实时计算

Continuous Integration

This pull request:

  • [ ] needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • [ ] does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • [ ] changes public API, and have ensured backward compatibility with deprecated features.
  • [ ] affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • [ ] affects file structure of the build package or build configuration which requires user project upgrade.
  • [ ] introduces breaking changes, please list all changes, affected features and the scope of violation.

yanjifa avatar Jun 04 '25 18:06 yanjifa

@star-e Please assign a reviewer

yanjifa avatar Jun 04 '25 18:06 yanjifa

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1006343 bytes 1006252 bytes 👍 -91 bytes
2D All (legacy pipeline) 2671535 bytes 2671440 bytes 👍 -95 bytes
2D All (new pipeline) 2760985 bytes 2760891 bytes 👍 -94 bytes
(2D + 3D) All 10017290 bytes 10017194 bytes 👍 -96 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16838813 bytes 16838717 bytes 👍 -96 bytes

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -2407,12 +2407,12 @@
         get verticalAlign(): VerticalTextAlignment;
         set verticalAlign(value: VerticalTextAlignment);
         /**
          * @en
-         * The actual rendering font size in shrink mode.
+         * The actual rendering font size.
          *
          * @zh
-         * SHRINK 模式下面文本实际渲染的字体大小。
+         * 文本实际渲染的字体大小。
          */
         get actualFontSize(): number;
         set actualFontSize(value: number);
         /**
@@ -2612,9 +2612,8 @@
         get _bmFontOriginalSize(): number;
         protected _string: string;
         protected _horizontalAlign: HorizontalTextAlignment;
         protected _verticalAlign: VerticalTextAlignment;
-        protected _actualFontSize: number;
         protected _fontSize: number;
         protected _fontFamily: string;
         protected _lineHeight: number;
         protected _overflow: Overflow;
@@ -2633,9 +2632,9 @@
         protected _enableShadow: boolean;
         protected _shadowColor: math.Color;
         protected _shadowOffset: math.Vec2;
         protected _shadowBlur: number;
-        protected _N$file: Font | null;
+        protected _actualFontSize: number;
         protected _texture: SpriteFrame | __private._cocos_2d_assembler_label_font_utils__LetterRenderTexture | null;
         protected _ttfSpriteFrame: SpriteFrame | null;
         protected _userDefinedFont: Font | null;
         protected _assemblerData: __private._cocos_2d_assembler_label_font_utils__ISharedLabelData | null;

github-actions[bot] avatar Jun 04 '25 19:06 github-actions[bot]