MCPcopy Create free account
hub / github.com/eva-engine/eva.js / addBitmapTextComponent

Method addBitmapTextComponent

packages/plugin-renderer-text/lib/system.ts:112–133  ·  view source on GitHub ↗
(changed: ComponentChanged)

Source from the content-addressed store, hash-verified

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 * 等待字体资源加载完成并更新文本

Callers 1

componentChangedMethod · 0.95

Calls 2

waitForFontResourceMethod · 0.95
getContainerMethod · 0.80

Tested by

no test coverage detected