# Keep text editable

[Canonical page](https://nothing.graphics/docs/format/guides/editable-text) · [Page source on GitHub](https://github.com/gridaco/nothing/blob/main/ncf/docs/guides/editable-text.md)

Style literal copy, replace a word at a key, or reproduce wrapped layout with a fixed font environment.



Use `text` as a shape’s geometry to keep the copy and paragraph settings editable. The text owns its first baseline `y`, its horizontal anchor `x`, and its base font family and size. Use the shape’s fill for the base ink. Put a `span` around a range that needs its own style or fill. Whitespace between spans is literal copy, so indent mixed content only when the added spaces and line breaks belong in the text. [Text content and paragraph fields](https://nothing.graphics/docs/format/spec/text#content-and-ownership)

## Replace one word at a key [#replace-one-word-at-a-key]

In the [moving-card scene](https://github.com/gridaco/nothing/blob/main/ncf/examples/composition-card.nothing), the line starts with the literal copy `Status READY.` and the status word belongs to a bold span. That span has a held `animate attributeName="value"` track. The period and preceding text remain part of the surrounding text. At frame 24 the span reads `WAIT` and its separate color track gives it a green fill. Change the frame-24 key’s `value` to `DONE` to edit that sampled word. Change the span’s character data to edit its base copy. Each edit targets a different source location.

Place replacement keys on a text or span without nested spans. The string target is spelled `value` inside `attributeName`; the key’s `value` attribute holds the replacement copy. For a literal newline in a key value, use `&#xA;`. [Copy ownership and replacement](https://nothing.graphics/docs/format/spec/text#content-and-ownership) · [Source edits](https://nothing.graphics/docs/format/guides/edit-source)

## Wrap and reproduce a layout [#wrap-and-reproduce-a-layout]

The [caption scene](https://github.com/gridaco/nothing/blob/main/ncf/conformance/fonts/caption.nothing) requests NCF Arithmetic at size 20. Its two A glyphs advance 24 units. The face lacks Cyrillic, so the two Ж glyphs use PT Serif and advance about 37.88 units. With `inline-size="44"` the words fall on separate lines at baselines 24 and 50. With `inline-size="74"` both words fit on the first line: 24 units for the first word, 12 for the space, and about 37.88 for the second word.

Bind both exact faces and hide installed fonts to reproduce that result. The name in the scene expresses a family request. The command supplies the actual font files. Run from the repository root after [setting up the shared fixtures](https://nothing.graphics/docs/format/guides/first-scene#render-and-edit-the-still).

```sh
(cd ncf && cargo run --locked -p ncf-preview -- \
  conformance/fonts/caption.nothing --fonts-only \
  --font 'NCF Arithmetic@400=conformance/attached-drawables/arithmetic.ttf' \
  --font 'PT Serif@400=../fixtures/fonts/PT_Serif/PTSerif-Regular.ttf' -o ../caption.svg)
```

When a family is missing, a host can report the request and substitute an available face. The original request stays in the file. The available faces, fallback order and shaping environment can change wrapping and ink. Share those inputs with the scene when the layout must repeat. [Font resolution](https://nothing.graphics/docs/format/spec/fonts#reproducing-a-layout) · [Independent glyph and baseline observations](https://github.com/gridaco/nothing/blob/main/ncf/conformance/fonts/README.md)

## Examples

[Download the complete .nothing source](https://nothing.graphics/format/editable-caption/source.nothing) · [Source on GitHub](https://github.com/gridaco/nothing/blob/main/ncf/conformance/fonts/caption.nothing)

Rendered with ncf-preview at 120 × 80.

Bound resources

- [fixtures/fonts/PT_Serif/PTSerif-Regular.ttf](https://github.com/gridaco/fixtures/blob/main/fonts/PT_Serif/PTSerif-Regular.ttf) for `PT Serif@400`
- [ncf/conformance/attached-drawables/arithmetic.ttf](https://github.com/gridaco/nothing/blob/main/ncf/conformance/attached-drawables/arithmetic.ttf) for `NCF Arithmetic@400`

- [Still · Wrapped caption](https://nothing.graphics/format/editable-caption/0.webp) at 0s. The two square primary glyphs share the first baseline. The two Cyrillic characters use the fallback face and wrap to the second baseline.

```xml
  <shape>
    <text x="4" y="24" font-family="NCF Arithmetic" font-size="20" inline-size="44" line-height="26">AA ЖЖ</text>
    <fill><paint><solid color="#FFFFFFFF"/></paint></fill>
  </shape>
```
