---
title: "Cover every script with fonts and break · Agent Wranglers"
url: https://agentwranglers.se/playbook/localization/layout-and-scripts/scripts-fonts-and-line-breaks
id: LOC-56
level: Recommended
updated: 2026-10-22
build: a2a6bdfed830
tokens: 833
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Cover every script with fonts and break words with a segmenter

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Layout and scripts](https://agentwranglers.se/playbook/localization/layout-and-scripts.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: LOC-56
- Level: Recommended
- Chapter: [Layout and scripts](https://agentwranglers.se/playbook/localization/layout-and-scripts.md)
- Rule: For each supported language, load or fall back to a font with all its characters, and set `lang` on the page. Find word boundaries with a segmenter, never by splitting on spaces.
- Check: A unit test segments "สวัสดีครับ" with the Thai locale and gets more than one word. A browser test renders a sample sentence in every supported language at phone width, and a screenshot shows no missing-glyph boxes.
- How: Thai, Lao, Khmer, Chinese and Japanese put no spaces between words. Code that splits on spaces sees one long word, so word counts, excerpts and highlights break in the middle of words. Use `Intl.Segmenter` with `granularity: 'word'` in JavaScript, or ICU's `BreakIterator` in Java and Python. Browsers break lines in these scripts only when `lang` names the language. The same Han character also takes a different shape in Japanese and Chinese, and `lang` picks the right one. End each font stack with a family that covers the script, such as a Noto font. Cut text by visible character as [Count and cut text by visible characters](https://agentwranglers.se/playbook/localization/text-handling/grapheme-clusters.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
const words = [...new Intl.Segmenter('th', { granularity: 'word' }).segment('สวัสดีครับ')]
  .filter(part => part.isWordLike).map(part => part.segment);
```

### Java example

```java
import java.text.BreakIterator;
import java.util.Locale;

BreakIterator words = BreakIterator.getWordInstance(Locale.forLanguageTag("th"));
words.setText("สวัสดีครับ");
```

## Sources

- [UAX #29 (Unicode Text Segmentation)](https://www.unicode.org/reports/tr29/)
- [UAX #14 (Unicode Line Breaking Algorithm)](https://www.unicode.org/reports/tr14/)
- [ECMA-402 (Segmenter objects)](https://tc39.es/ecma402/#segmenter-objects)

## Related rules

- LOC-50 [Count and cut text by visible characters](https://agentwranglers.se/playbook/localization/text-handling/grapheme-clusters.md) in Localization

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/localization/layout-and-scripts/scripts-fonts-and-line-breaks">Agent Wranglers localization playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Wait for text composition to end before acting on Enter](https://agentwranglers.se/playbook/localization/layout-and-scripts/input-composition.md)
- [Layout and scripts](https://agentwranglers.se/playbook/localization/layout-and-scripts.md)
