* Request characters to be available in the atlas * 请求字符在图集中可用 * * Similar to Unity's Font.RequestCharactersInTexture
(text: string)
| 247 | * Similar to Unity's Font.RequestCharactersInTexture |
| 248 | */ |
| 249 | public requestCharacters(text: string): void { |
| 250 | let hasNew = false; |
| 251 | |
| 252 | for (let i = 0; i < text.length; i++) { |
| 253 | const charCode = text.charCodeAt(i); |
| 254 | |
| 255 | // Skip if already cached |
| 256 | if (this._glyphs.has(charCode)) continue; |
| 257 | |
| 258 | // Skip control characters |
| 259 | if (charCode < 32 && charCode !== 9 && charCode !== 10 && charCode !== 13) continue; |
| 260 | |
| 261 | // Render the character |
| 262 | if (this.renderCharacter(charCode)) { |
| 263 | hasNew = true; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | // Upload texture if needed |
| 268 | if (hasNew && this._onTextureUpload && this._dirtyRegion) { |
| 269 | this.uploadTexture(); |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * Render a character to the atlas |
no test coverage detected