A browser sets a line, forgets it, and sets the next. A compositor looks at the whole paragraph before committing to any of it. The distance between those two pages, in points of colour, is the greedy gap. Every paragraph on the web has one. Now you can read it.
Choose the breaks for the whole paragraph at once, by the least total demerits over every line. This is the Knuth and Plass algorithm of 1981, extended so that each line has its own measure, because around a figure no two lines are alike. Tolerance , tried in order. Beam of live breakpoints.
Word space sits at a quarter of an em and moves little. No more white should be used between the words than just clearly cuts them off from one another.
That is Morris, in The Ideal Book. Space em, stretch , shrink .
Let the glyphs take a little of the strain, too small to see, so the word spaces do not take it all. Morris would object; he hated compressed letters. At under two per cent, you will not catch it. Scale ±.
A comma at the end of a line weighs almost nothing, so a straight margin through it looks dented. Let periods, commas, quotes and hyphens hang outside the measure, and the edge of the column comes up straight. It applies along the figure as well as the margin.
The same for letters. An A or a T opens white at its corner, so it moves out by a few hundredths of an em.
Each one costs. Two running cost more; three is a ladder and the proofreader marks it. A word never breaks across the figure, and seldom across a column. Hyphen , two running , across the figure , across a column .
Morris asked for the breaking of the line as in bonding masonry or brickwork
. Word spaces stacked on neighbouring lines cost demerits, so a river pays before it forms. Honest measure: across a sweep of 246 positions this cut the loose stacks by about a third. It did nothing for wide rivers, because total fit had already removed them. Bond for each stacked pair, within em.
A paragraph’s last line does not sit alone at the head of a column; its first does not sit alone at the foot. The second is only solvable from the paragraph before, so a paragraph pays for stranding the next. Each . High, not infinite: a figure can force one, and the marks will show it.
A last line should be more than one short word. Under of the measure costs .
Text follows the alpha matte of the cut-out, read row by row, and not a circle or a polygon near it. A line the figure runs through becomes two slots and reads across. Slots under em stay white.
Every line in both columns sits on one grid, on whole pixels. The figure may move the words along a line, never the line.
A rule print never needed. Total fit is global, so one pixel of drag can rebreak a distant paragraph and the page shimmers. A break that held last frame is made cheaper, so text moves only when moving is worth it. Demerits × .
The page’s score out of 100. Printers call the evenness of a page its colour. Here it is 100 × (1 − 0.5 uneven − 0.35 rivers − 0.15 faults). Uneven is how far word spaces stray from natural. Rivers are spaces overlapping by 0.15 em down three lines or more, three counting only when 15% over natural. Faults are ladders, widows, orphans and runts. The weights are a judgement, not a standard.
True italics, not slanted roman. True small capitals, not shrunk ones. Old-style figures in running text and in every number on the page. Morris on modern figures: the eyes must be strained before the reader can have any reasonable assurance that he has a 5, an 8, or a 3 before him.
import { prepare, setPage, lineWords, slotsFor, silhouette, placed } from "./proof.js";
const measure = (text, style) => ctx.measureText(text).width;
const para = prepare("Softhyphens mark the breakpoints.", measure, { fontSize: 21 });
const shape = silhouette(ctx.getImageData(0, 0, w, h));
const slots = slotsFor([{ x: 80, y: 90, w: 600, h: 700 }], 26,
[placed(shape, figX, figY, figW, figH, 13)], { fontSize: 21 });
const page = setPage([para], slots); // { lines, colour, rivers, stacks, marks }
for (const line of page.lines)
for (const word of lineWords(para, line)) draw(word.text, word.x, line.y, line.scale);