Manual
Almnck.
Price: 50ⓐ

Justif: TeX-Style Justification

Date: 2026-07-25 Status: Adopted — justif ships on main (0.6.4, on by default, no toggle). See Update / Adopted below. Critique: Browser justification is crude; can we get whole-paragraph, TeX-quality line breaking?

The Problem

The body text uses CSS text-align: justify, which breaks lines greedily, one at a time. It produces uneven word spacing and the occasional river of whitespace — exactly the thing the antique-print aesthetic should avoid. justif is a small MIT-licensed library that runs the Knuth–Plass algorithm (the one TeX uses) over whole paragraphs in the browser, adding hyphenation and optical margins on top.

The Experiment

Built a full working integration on the justif-demo branch:

  • Vendored justif, self-hosted, no CDN (version-named dir for cache-busting).
  • A render-blocking ES module justifies main-column body prose before first paint, so text lands already justified — no reflow flash.
  • A masthead “Justif ✓” toggle flips it against the native CSS rendering live, for side-by-side comparison.

Where it works, the typography is genuinely better: even spacing, sensible hyphenation, hanging punctuation.

Three real problems surfaced along the way, two of them ours and fixed:

  • justif skipped every footnote-bearing paragraph, because .footnote-ref was inline-block and its CSS [ ] brackets were invisible to justif’s width measurement. Fixed by making the ref inline and realising the brackets as real text nodes.
  • justif blew our margin sidenotes into horizontal overflow at every desktop width — it pins a managed paragraph’s intrinsic width, which wrecks a shrink-to-fit margin column. Fixed by restricting justif to the main column.

What We Found

The blocker is the third problem, and it is justif’s, not ours: on some paragraphs justif’s deferred correction pass inflates a line’s word-spacing to 50–75px (healthy is ~2px), flinging the words across the measure and into the margin. We root-caused it — the correction reads an empty .justif-hyphen marker’s bounding rect at the start of the line instead of the end, producing a ~640px bogus adjustment — and confirmed it still reproduces on the current release (0.6.1), so upgrading doesn’t rescue it. Full detail in docs/superpowers/justif-known-issues.md; reported upstream as justif#10 with a standalone repro under docs/superpowers/justif-upstream/.

Decision

Rejected for now. The gain is real but a library that renders some paragraphs visibly broken on the live site can’t ship, and there’s no clean workaround on our side. The implementation is parked, working, on branch justif-demo (with the A/B toggle) so it can be re-evaluated the moment the upstream bug is fixed — nothing needs rebuilding, just a version bump and a re-test of the word-spacing guard.

Lesson

Client-side typography this ambitious is worth wanting, but it’s only as reliable as the library’s weakest render path — and “the latest release fixes it” is a hypothesis to test, not assume (0.6.1 didn’t). Keep the evaluation on a throwaway branch with a live toggle: it’s what turned “this looks broken” into a root-caused, reproducible upstream bug report in an afternoon, on a worktree that never touched the live site.

Update — the blocker was fixed upstream

Lyall Cooper fixed the word-spacing blowout in justif 0.6.3. His diagnosis completes ours: we had traced the mechanism (the deferred correction pass mis-reading a hyphen marker’s rect) but flagged that we hadn’t chased down why the browser positioned that line box wrong. The trigger was overflow-wrap: break-word (and its kin) on managed prose — the browser’s emergency word breaking fighting justif’s own layout. Almanack body text carries overflow-wrap: break-word, which is exactly why we hit it.

Verified rather than trusted, per the lesson above: re-ran our standalone width-sweep repro against 0.6.1 / 0.6.3 / 0.6.4 on the same machine and font. 0.6.1 still blows out (53px at 480px width); 0.6.3 and 0.6.4 sweep the whole 480–880px band with no triggering width. The other reporter on the issue independently confirmed the fix.

Revived on the branch. Bumped the vendored copy to 0.6.4, updated the init/import paths and the version-pinned tests, rebuilt, and re-ran the suites. The justif tests (all 8 browser + 6 file/wiring) pass. The word-spacing < 20px guard — the one that shelved this — now passes on the real article. The full desktop browser suite shows the same failure set as before the bump (celestial 404s, the 320px-overflow case, the flaky margin-nudge, and six pre-existing mobile footnote tap-target failures — issue #3 below, confirmed identical at 0.5.1), so the bump introduces no regressions.

The softer tradeoffs remain, documented in docs/superpowers/justif-known-issues.md: the Chromium-only render-blocking flash, the shrunk footnote tap target, and the per-navigation Knuth–Plass cost — none a blocker.

Adopted

Merged to main. justif runs unconditionally on load, no reader-facing toggle (the masthead button and click-to-flick were eval scaffolding, removed before merge). Two things left deliberately as-is:

  • Drop-cap opening paragraph — excluded. Investigated on 0.6.4: justif’s own drop-cap support only understands a floated CSS ::first-letter (text); Almanack’s drop cap is a floated illuminated image, and justif bails on the whole paragraph with onSkip reason “non-inline-flow “. Getting it in would mean either dropping the woodcut initial for a text letter or moving the float out of the paragraph and reworking the ::first-line small-caps — high effort against a signature visual, on the one paragraph where even spacing matters least (the eye is on the drop cap). Not worth it.
  • Generated-content measurement (justif ignores CSS ::before/::after): worked around with realizeFootnoteBrackets(); the upstream limitation is noted as fixable in docs/superpowers/justif-upstream/ISSUE-2-*.