Field report · justif in the wild

We ran justif on an 1787 newspaper

Federalist Reader presents the Federalist Papers as facsimile front pages of the newspapers that first printed them. Its Gazette view reproduces The Independent Journal — in IM FELL DW Pica, two 356 px columns, drop caps — but for its first week it set the text ragged-right, which no 1787 compositor would have shipped. We ran justif against the live page to see what it would do. It was made for this — and within days, justif was setting every essay on the site in production.

356 pxreal column measure, IM FELL DW Pica 17.63 px / 24.32 px — a hostile, narrow case
~280 msto enhance all 23 paragraphs of Federalist No. 10, Chromium, mid-range laptop
0 hyphensneeded in the specimen below, where the browser’s greedy breaker uses two
0.5.0the justif release now setting every Gazette page on the live site

The same passage, three ways

Real markup and font from the live site, at the exact 356 px measure. The right panel is frozen output of justif running against the page — every line’s word-spacing, letter-spacing, and protrusion is what the engine computed, serialized verbatim.

Before — ragged right

text-align: left; hyphens: auto

By a faction, I understand a number of citizens, whether amounting to a majority or a minority of the whole, who are united and actuated by some common impulse of passion, or of interest, adversed to the rights of other citizens, or to the permanent and aggregate interests of the community.

There are two methods of curing the mischiefs of faction: the one, by removing its causes; the other, by controlling its effects.

There are again two methods of removing the causes of faction: the one, by destroying the liberty which is essential to its existence; the other, by giving to every citizen the same opinions, the same passions, and the same interests.

Native CSS justify

text-align: justify; hyphens: auto — one line at a time, spaces stretched to fit

By a faction, I understand a number of citizens, whether amounting to a majority or a minority of the whole, who are united and actuated by some common impulse of passion, or of interest, adversed to the rights of other citizens, or to the permanent and aggregate interests of the community.

There are two methods of curing the mischiefs of faction: the one, by removing its causes; the other, by controlling its effects.

There are again two methods of removing the causes of faction: the one, by destroying the liberty which is essential to its existence; the other, by giving to every citizen the same opinions, the same passions, and the same interests.

justif — Knuth–Plass

Whole-paragraph optimization + hanging punctuation, frozen from the live run

By a faction, I understand a number of citizens, whether amounting to a majority or a minority of the whole, who are united and actuated by some common impulse of passion, or of interest, adversed to the rights of other citizens, or to the permanent and aggregate interests of the community.

There are two methods of curing the mischiefs of faction: the one, by removing its causes; the other, by controlling its effects.

There are again two methods of removing the causes of faction: the one, by destroying the liberty which is essential to its existence; the other, by giving to every citizen the same opinions, the same passions, and the same interests.

What impressed us

Even color. No stretched lines

Both justified panels reach the margin, but the native panel gets there by stretching spaces on whichever line came up short. In justif’s panel the computed word-spacing deviates by fractions of a pixel per line, because the engine re-chose every break in the paragraph at once.

Hanging punctuation. Commas cross the guide

Line-ending commas and final periods hang past the right margin guide (the −5 to −6 px margin-inline-end in the frozen markup), so the letterforms define the optical edge. On a facsimile of hand-set newsprint this reads as period-correct, not decorative.

Restraint with hyphens. Zero where greedy needs two

The browser hyphenates this short passage twice (caus-es, giv-ing in Chromium). Justif, given the same en-US TeX patterns, found whole-paragraph solutions that needed none at a 356 px measure.

It survives contact with a weird site.

Two-column facsimile layout, self-hosted revival fonts, small caps, inline italics: everything Just Worked from a console injection, and selection, find-in-page, and the DOM’s semantics stayed intact. (The drop-cap opener keeps the browser’s native justification by design, sitting exactly as a compositor would have locked it.)

From experiment to production

This page began as a field report sent to justif’s author during the library’s Show HN week. Days later, justif 0.5.0 was live and so were we: every essay on federalistreader.org is now set with whole-paragraph justification and hanging punctuation, the way its 1787 originals were set by hand. The big Fell drop caps keep the browser’s native justification by design. Open any paper and look at the right edge.