Line breaking for CJK text — why word-wrap logic falls apart
Text wrapping built for English treats a space as the boundary between words: fill the line with whole words until the next one would overflow, then break before it. Japanese sentences do not have that boundary at all — there are no spaces between words. A wrapping implementation that assumes one exists either treats the whole Japanese string as a single unbreakable 'word' and never wraps, overflowing its container indefinitely, or falls back to breaking at every character with no regard for which characters that is actually allowed at.
Kinsoku shori: line breaking is per character, with rules
Correct Japanese line breaking operates per character rather than per word, governed by a set of rules known as kinsoku shori (禁則処理, 'prohibition processing'). Certain characters are forbidden from starting a line, and a different set is forbidden from ending one.
- Line-start prohibition: closing brackets and quotation marks, Japanese punctuation such as the comma (、) and full stop (。), and small kana used for gemination and contracted sounds (っ, ゃ, ゅ, ょ, and the long-vowel mark ー) may never begin a line. They are pulled back to hang off the end of the previous line, or the break moves earlier to keep them attached to the preceding character.
- Line-end prohibition: opening brackets and quotation marks may never end a line — the break moves so the opening bracket starts the following line instead.
Why manual newlines betray you after translation
It is tempting to hand-place a newline character in a source string so a dialogue box breaks at a visually pleasing spot — say, right before the second clause of an English sentence. That break point was chosen for English word order and English sentence length. Once the string is translated, both the word order and the length change, and the original break position stops meaning anything.
In the worst case, that hardcoded newline lands mid-word in the translated language, or right before a character that Japanese line-breaking rules forbid from starting a line — producing a visibly broken line that no amount of a well-implemented wrapping engine can fix, because the break itself was baked into the translatable text rather than left to the layout.
What to actually do
None of this requires exotic tooling, just getting the defaults right.
- Use your text rendering system's CJK-aware wrapping mode. Most game engines and UI frameworks that support CJK text ship a mode that wraps per character and applies kinsoku shori rules — do not reuse the plain word-wrap path for Japanese strings.
- Keep hard newlines out of translatable strings wherever possible. Line breaks should be a layout decision made dynamically, not a value baked into the source text to match how the English happened to look. Where an intentional break is unavoidable (a stylized two-line title, for instance), make the break position overridable per language.
- Test with real translated Japanese strings, not placeholder or romanized text — wrapping and kinsoku behavior can only be verified against the actual character sequence a player will see.