(changed: ComponentChanged)
| 110 | } |
| 111 | |
| 112 | private async addBitmapTextComponent(changed: ComponentChanged) { |
| 113 | const component = changed.component as BitmapTextComponent; |
| 114 | |
| 115 | // 创建样式副本,先不设置 fontFamily |
| 116 | const styleWithoutFont = { ...component.style }; |
| 117 | const fontFamily = styleWithoutFont.fontFamily; |
| 118 | delete styleWithoutFont.fontFamily; |
| 119 | const initialText = fontFamily ? '' : component.text; |
| 120 | |
| 121 | const bitmapText = new BitmapTextEngine(initialText, styleWithoutFont); |
| 122 | |
| 123 | this.containerManager.getContainer(changed.gameObject.id).addChildAt(bitmapText, 0); |
| 124 | this.texts[changed.gameObject.id] = { |
| 125 | text: bitmapText, |
| 126 | component, |
| 127 | }; |
| 128 | |
| 129 | // 如果指定了字体资源,等待资源加载完成后设置 fontFamily |
| 130 | if (fontFamily) { |
| 131 | await this.waitForFontResource(bitmapText, changed, fontFamily); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * 等待字体资源加载完成并更新文本 |
no test coverage detected