FA-80151 / Typography line breaking / Open access
Runt last-line prevention: overwide word isolation · case 01
Overwide words are attached to the current line or leave empty lines.
ROOT CAUSE
Overwide words are appended to a non-empty line instead of starting their own.
THE FAILURE
Overwide words are appended to a non-empty line instead of starting their own.
Unsuccessful approach: Special-casing only the first word still merges later overwide words.
Case contract
Input [words, width, minimum last-line length]. Greedy fill (unit spaces; overwide word alone). Then while there are at least two lines and the last line string is shorter than the minimum, move the last word of the previous line down if that line keeps at least one word and the new last line fits. Return lines.
Why this case matters
Line breaking decides where paragraphs wrap on screen and in print; a wrong decision point shifts every following line.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
words, width, min_last = x
lines = []
cur = ''
for w in words:
cand = w if not cur else cur + ' ' + w
if len(cand) <= width or len(w) > width:
cur = cand
else:
lines.append(cur)
cur = w
lines.append(cur)
while len(lines) >= 2 and len(lines[-1]) < min_last:
prev = lines[-2].split(' ')
if len(prev) < 2:
break
moved = prev[-1] + ' ' + lines[-1]
if len(moved) > width:
break
lines[-2] = ' '.join(prev[:-1])
lines[-1] = moved
return lines
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: overwide word isolation', [['on', 'ink', 'x', 'at', 'a', 'kerning', 'serif', 'measure', 'at', 'baseline'], 7, 3], ['on ink', 'x at a', 'kerning', 'serif', 'measure', 'at', 'baseline']), ('regression: overwide word isolation', [['on', 'of', 'kerning', 'on', 'kerning', 'grid', 'baseline', 'grid', 'a', 'measure', 'at', 'measure'], 5, 4], ['on of', 'kerning', 'on', 'kerning', 'grid', 'baseline', 'grid', 'a', 'measure', 'at', 'measure']), ('partial-repair probe', [['a', 'ink', 'measure', 'serif', 'baseline'], 14, 5], ['a ink measure', 'serif baseline']), ('partial-repair probe', [['baseline', 'on', 'grid', 'kerning', 'a', 'ink', 'baseline', 'measure', 'a'], 10, 3], ['baseline', 'on grid', 'kerning a', 'ink', 'baseline', 'measure a']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['a', 'x', 'grid'], 13, 9], ['a x grid']), ('control layout', [['serif', 'a', 'the'], 17, 4], ['serif a the'])], [('regression: overwide word isolation', [['serif', 'baseline', 'grid', 'of', 'is', 'kerning'], 5, 8], ['serif', 'baseline', 'grid', 'of is', 'kerning']), ('regression: overwide word isolation', [['a', 'baseline', 'the', 'a', 'type', 'kerning', 'is', 'serif', 'a', 'grid', 'the'], 6, 3], ['a', 'baseline', 'the a', 'type', 'kerning', 'is', 'serif', 'a grid', 'the']), ('partial-repair probe', [['on', 'ink', 'type', 'a'], 12, 4], ['on ink', 'type a']), ('regression: overwide word isolation', [['baseline', 'a', 'a', 'is', 'a', 'type', 'on', 'baseline', 'serif', 'baseline', 'serif'], 7, 8], ['baseline', 'a a is', 'a type', 'on', 'baseline', 'serif', 'baseline', 'serif']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['on', 'is', 'at'], 17, 3], ['on is at']), ('control layout', [['x', 'on', 'serif'], 18, 4], ['x on serif'])], [('regression: overwide word isolation', [['kerning', 'grid', 'a', 'kerning', 'serif', 'is', 'the', 'kerning', 'baseline', 'serif'], 7, 4], ['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif']), ('regression: overwide word isolation', [['on', 'at', 'grid', 'measure', 'type', 'measure', 'on', 'x', 'at', 'a', 'baseline'], 7, 5], ['on at', 'grid', 'measure', 'type', 'measure', 'on x at', 'a', 'baseline']), ('partial-repair probe', [['grid', 'serif', 'at', 'measure'], 15, 3], ['grid serif at', 'measure']), ('partial-repair probe', [['ink', 'the', 'kerning', 'x', 'kerning'], 18, 7], ['ink the kerning x', 'kerning']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['is', 'measure', 'at'], 19, 4], ['is measure at']), ('control layout', [['measure', 'on', 'x', 'ink'], 16, 7], ['measure on x ink'])], [('regression: overwide word isolation', [['the', 'serif', 'baseline', 'x', 'a', 'baseline', 'measure', 'ink', 'of', 'measure', 'the'], 6, 8], ['the', 'serif', 'baseline', 'x a', 'baseline', 'measure', 'ink of', 'measure', 'the']), ('regression: overwide word isolation', [['on', 'of', 'kerning', 'on', 'kerning', 'grid', 'baseline', 'grid', 'a', 'measure', 'at', 'measure'], 5, 4], ['on of', 'kerning', 'on', 'kerning', 'grid', 'baseline', 'grid', 'a', 'measure', 'at', 'measure']), ('partial-repair probe', [['at', 'a', 'on', 'grid', 'grid', 'measure', 'the', 'x', 'at', 'at', 'type'], 20, 8], ['at a on grid grid', 'measure the x', 'at at type']), ('regression: overwide word isolation', [['serif', 'of', 'at', 'the', 'measure', 'ink', 'ink', 'a', 'x'], 5, 8], ['serif', 'of at', 'the', 'measure', 'ink', 'ink', 'a x']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['x', 'on', 'serif'], 18, 4], ['x on serif']), ('control layout', [['is', 'the', 'serif'], 12, 9], ['is the serif'])], [('regression: overwide word isolation', [['baseline', 'serif', 'is', 'baseline', 'x', 'x', 'at', 'is', 'serif', 'at', 'at'], 6, 9], ['baseline', 'serif', 'is', 'baseline', 'x x at', 'is', 'serif', 'at at']), ('regression: overwide word isolation', [['on', 'at', 'a', 'at', 'type', 'of', 'a', 'baseline', 'ink', 'ink', 'serif', 'baseline'], 5, 7], ['on at', 'a at', 'type', 'of a', 'baseline', 'ink', 'ink', 'serif', 'baseline']), ('partial-repair probe', [['of', 'at', 'ink', 'measure', 'at', 'the', 'measure', 'ink'], 11, 6], ['of at ink', 'measure at', 'the', 'measure ink']), ('partial-repair probe', [['ink', 'kerning', 'ink'], 8, 9], ['ink', 'kerning', 'ink']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('control layout', [['type', 'the', 'a'], 18, 3], ['type the a']), ('control layout', [['a', 'is', 'serif'], 11, 3], ['a is serif'])]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: overwide word isolation | ['on ink', 'x at a', 'kerning', 'serif', 'measure', 'at baseline'] | ['on ink', 'x at a', 'kerning', 'serif', 'measure', 'at', 'baseline'] | Failed |
| regression: overwide word isolation | ['on of kerning', 'on kerning', 'grid baseline', 'grid', 'a measure', 'at measure'] | ['on of', 'kerning', 'on', 'kerning', 'grid', 'baseline', 'grid', 'a', 'measure', 'at', 'measure'] | Failed |
| partial-repair probe | ['a ink measure', 'serif baseline'] | ['a ink measure', 'serif baseline'] | Passed |
| partial-repair probe | ['baseline', 'on grid', 'kerning a', 'ink', 'baseline', 'measure a'] | ['baseline', 'on grid', 'kerning a', 'ink', 'baseline', 'measure a'] | Passed |
| one-word runt pulled down | ['the type', 'grid is a'] | ['the type', 'grid is a'] | Passed |
| runt limited by width | ['kerning', 'baseline x'] | ['kerning', 'baseline x'] | Passed |
| control layout | ['a x grid'] | ['a x grid'] | Passed |
| control layout | ['serif a the'] | ['serif a the'] | Passed |
SHA-256 / a636b396cd6c5b50bf453463b240c6779fd9ea6f39c12d31f9167f3c0480d240
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
words, width, min_last = x
lines = []
cur = ''
for w in words:
cand = w if not cur else cur + ' ' + w
if len(cand) <= width or not lines:
cur = cand
else:
lines.append(cur)
cur = w
lines.append(cur)
while len(lines) >= 2 and len(lines[-1]) < min_last:
prev = lines[-2].split(' ')
if len(prev) < 2:
break
moved = prev[-1] + ' ' + lines[-1]
if len(moved) > width:
break
lines[-2] = ' '.join(prev[:-1])
lines[-1] = moved
return lines
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: overwide word isolation', [['on', 'ink', 'x', 'at', 'a', 'kerning', 'serif', 'measure', 'at', 'baseline'], 7, 3], ['on ink', 'x at a', 'kerning', 'serif', 'measure', 'at', 'baseline']), ('regression: overwide word isolation', [['on', 'of', 'kerning', 'on', 'kerning', 'grid', 'baseline', 'grid', 'a', 'measure', 'at', 'measure'], 5, 4], ['on of', 'kerning', 'on', 'kerning', 'grid', 'baseline', 'grid', 'a', 'measure', 'at', 'measure']), ('partial-repair probe', [['a', 'ink', 'measure', 'serif', 'baseline'], 14, 5], ['a ink measure', 'serif baseline']), ('partial-repair probe', [['baseline', 'on', 'grid', 'kerning', 'a', 'ink', 'baseline', 'measure', 'a'], 10, 3], ['baseline', 'on grid', 'kerning a', 'ink', 'baseline', 'measure a']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['a', 'x', 'grid'], 13, 9], ['a x grid']), ('control layout', [['serif', 'a', 'the'], 17, 4], ['serif a the'])], [('regression: overwide word isolation', [['serif', 'baseline', 'grid', 'of', 'is', 'kerning'], 5, 8], ['serif', 'baseline', 'grid', 'of is', 'kerning']), ('regression: overwide word isolation', [['a', 'baseline', 'the', 'a', 'type', 'kerning', 'is', 'serif', 'a', 'grid', 'the'], 6, 3], ['a', 'baseline', 'the a', 'type', 'kerning', 'is', 'serif', 'a grid', 'the']), ('partial-repair probe', [['on', 'ink', 'type', 'a'], 12, 4], ['on ink', 'type a']), ('regression: overwide word isolation', [['baseline', 'a', 'a', 'is', 'a', 'type', 'on', 'baseline', 'serif', 'baseline', 'serif'], 7, 8], ['baseline', 'a a is', 'a type', 'on', 'baseline', 'serif', 'baseline', 'serif']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['on', 'is', 'at'], 17, 3], ['on is at']), ('control layout', [['x', 'on', 'serif'], 18, 4], ['x on serif'])], [('regression: overwide word isolation', [['kerning', 'grid', 'a', 'kerning', 'serif', 'is', 'the', 'kerning', 'baseline', 'serif'], 7, 4], ['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif']), ('regression: overwide word isolation', [['on', 'at', 'grid', 'measure', 'type', 'measure', 'on', 'x', 'at', 'a', 'baseline'], 7, 5], ['on at', 'grid', 'measure', 'type', 'measure', 'on x at', 'a', 'baseline']), ('partial-repair probe', [['grid', 'serif', 'at', 'measure'], 15, 3], ['grid serif at', 'measure']), ('partial-repair probe', [['ink', 'the', 'kerning', 'x', 'kerning'], 18, 7], ['ink the kerning x', 'kerning']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['is', 'measure', 'at'], 19, 4], ['is measure at']), ('control layout', [['measure', 'on', 'x', 'ink'], 16, 7], ['measure on x ink'])], [('regression: overwide word isolation', [['the', 'serif', 'baseline', 'x', 'a', 'baseline', 'measure', 'ink', 'of', 'measure', 'the'], 6, 8], ['the', 'serif', 'baseline', 'x a', 'baseline', 'measure', 'ink of', 'measure', 'the']), ('regression: overwide word isolation', [['on', 'of', 'kerning', 'on', 'kerning', 'grid', 'baseline', 'grid', 'a', 'measure', 'at', 'measure'], 5, 4], ['on of', 'kerning', 'on', 'kerning', 'grid', 'baseline', 'grid', 'a', 'measure', 'at', 'measure']), ('partial-repair probe', [['at', 'a', 'on', 'grid', 'grid', 'measure', 'the', 'x', 'at', 'at', 'type'], 20, 8], ['at a on grid grid', 'measure the x', 'at at type']), ('regression: overwide word isolation', [['serif', 'of', 'at', 'the', 'measure', 'ink', 'ink', 'a', 'x'], 5, 8], ['serif', 'of at', 'the', 'measure', 'ink', 'ink', 'a x']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['x', 'on', 'serif'], 18, 4], ['x on serif']), ('control layout', [['is', 'the', 'serif'], 12, 9], ['is the serif'])], [('regression: overwide word isolation', [['baseline', 'serif', 'is', 'baseline', 'x', 'x', 'at', 'is', 'serif', 'at', 'at'], 6, 9], ['baseline', 'serif', 'is', 'baseline', 'x x at', 'is', 'serif', 'at at']), ('regression: overwide word isolation', [['on', 'at', 'a', 'at', 'type', 'of', 'a', 'baseline', 'ink', 'ink', 'serif', 'baseline'], 5, 7], ['on at', 'a at', 'type', 'of a', 'baseline', 'ink', 'ink', 'serif', 'baseline']), ('partial-repair probe', [['of', 'at', 'ink', 'measure', 'at', 'the', 'measure', 'ink'], 11, 6], ['of at ink', 'measure at', 'the', 'measure ink']), ('partial-repair probe', [['ink', 'kerning', 'ink'], 8, 9], ['ink', 'kerning', 'ink']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('control layout', [['type', 'the', 'a'], 18, 3], ['type the a']), ('control layout', [['a', 'is', 'serif'], 11, 3], ['a is serif'])]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: overwide word isolation | ['on ink x at a kerning serif measure at baseline'] | ['on ink', 'x at a', 'kerning', 'serif', 'measure', 'at', 'baseline'] | Failed |
| regression: overwide word isolation | ['on of kerning on kerning grid baseline grid a measure at measure'] | ['on of', 'kerning', 'on', 'kerning', 'grid', 'baseline', 'grid', 'a', 'measure', 'at', 'measure'] | Failed |
| partial-repair probe | ['a ink measure serif baseline'] | ['a ink measure', 'serif baseline'] | Failed |
| partial-repair probe | ['baseline on grid kerning a ink baseline measure a'] | ['baseline', 'on grid', 'kerning a', 'ink', 'baseline', 'measure a'] | Failed |
| one-word runt pulled down | ['the type grid is a'] | ['the type', 'grid is a'] | Failed |
| runt limited by width | ['kerning baseline x'] | ['kerning', 'baseline x'] | Failed |
| control layout | ['a x grid'] | ['a x grid'] | Passed |
| control layout | ['serif a the'] | ['serif a the'] | Passed |
SHA-256 / 09a54d9d37a4e5ce15044c3740b0df134e68368b0790e133b7baec9f615e0354
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
A deterministic toy typesetting model with integer widths and a stipulated rule set; it does not claim conformance to any engine. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:49:51.156284+00:00.
Case digest / 17b456ea38cdc8c3d6706b5e8e010cc90fb69610e1bef73441e15b5658150d16