(changed: ComponentChanged)
| 84 | } |
| 85 | |
| 86 | private async addHTMLTextComponent(changed: ComponentChanged) { |
| 87 | const component = changed.component as HTMLTextComponent; |
| 88 | |
| 89 | // 创建样式副本,先不设置 fontFamily |
| 90 | const styleWithoutFont = { ...component.style }; |
| 91 | const fontFamily = styleWithoutFont.fontFamily; |
| 92 | delete styleWithoutFont.fontFamily; |
| 93 | const initialText = fontFamily ? '' : component.text; |
| 94 | |
| 95 | const htmlText = new HTMLTextEngine({ |
| 96 | text: initialText, |
| 97 | style: styleWithoutFont, |
| 98 | ...(component.textureStyle && { textureStyle: component.textureStyle }) |
| 99 | } as any); |
| 100 | |
| 101 | this.containerManager.getContainer(changed.gameObject.id).addChildAt(htmlText, 0); |
| 102 | this.texts[changed.gameObject.id] = { |
| 103 | text: htmlText, |
| 104 | component, |
| 105 | }; |
| 106 | // 如果指定了字体资源,等待资源加载完成后设置 fontFamily |
| 107 | if (fontFamily) { |
| 108 | await this.waitForFontResource(htmlText, changed, fontFamily); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | private async addBitmapTextComponent(changed: ComponentChanged) { |
| 113 | const component = changed.component as BitmapTextComponent; |
no test coverage detected