# `@combos-fun/plugin-renderer-text` — Agent notes

2D labels. Not bitmap-atlas text.

```ts
import { Text, TextSystem } from '@combos-fun/plugin-renderer-text';
```

`Text.componentName = 'Text'`. `TextSystem.systemName = 'Text'`.

`text` is required. It is the full source sentence. Every player-facing string goes in `text`: titles, buttons, HUD labels, menus, toasts, instructions. Do not leave fixed words outside `text`, and do not build a sentence by joining pieces.

Only values that change with logic go in `replacements` (`{player}`, `{score}`): scores, counts, timers, names. Do not splice those into `text`.

`style` merges onto `{ fontSize: 20 }`. Style fields: `fill`, `fontFamily`, `fontSize`, `fontWeight`, `align`, `wordWrap`, `wordWrapWidth`, `breakWords`, `lineHeight`, `letterSpacing`, `padding`, `stroke`, `dropShadow`, `backgroundColor`. Wrapping needs `wordWrap: true` and `wordWrapWidth` in pixels. `Transform2D.size` does not set that width. A run with no spaces also needs `breakWords: true`. `align` aligns lines inside `wordWrapWidth`. Rendered bounds overwrite `Transform2D.size`.

**MUST** `new TextSystem({ sourceLocale, sourceTexts })`. `sourceLocale` is the written language of those strings (`en`, `zh-CN`, `ja-JP`), not the device locale. `sourceTexts` lists every template, including later screens. `declareSourceTexts([...])` during `onSystemsBootstrapComplete` also works. Omitting `sourceLocale` leaves every label in the source language. Load webfonts before adding `Text`. `fill` accepts a number, `#rgb`, `#rrggbb`, or `0x...`.

Tag the same GameObject with `LayoutRegion` (`role: "text"` or `"hud"`).

```ts
new TextSystem({ sourceLocale: 'zh-CN', sourceTexts: ['{player} 得分 {score}'] });
score.addComponent(new Text({
  text: '{player} 得分 {score}',
  replacements: { player: 'Alice', score: 100 },
  style: { fontSize: 32, fill: 0xffffff },
}));
```
