Forum Samples, Tips and Tricks

Avoiding runts with the Boxtracking API and variable fonts / microtypography

howcome
In typography, a "runt" is a short line at the end of a paragraph. Typographers generally try to avoid runts. I've added two examples that use the Prince Boxtracking API to avoid runts. The first example reduces "letter-spacing" in runt-infested paragraphs:

https://css4.pub/2024/boxtracking/#avoiding-runts

The second example uses variable fonts to narrow the glyphs so that more letters will fit on a line:

https://css4.pub/2024/boxtracking/#avoiding-runts-with-variable-fonts

To make variable fonts work on your own computer, you will need a recent version of Prince:

https://princexml.com/latest

The techniques used is also known as microtypography:

https://en.wikipedia.org/wiki/Microtypography

This is work in progress, use with care.

Edited by howcome

pjrm
Prince for Books has some degree of avoidance of runts by default, particularly last lines shorter than about the text-indent or shorter than about 4em. Compared to the output of normal Prince, it gives fewer last lines of length up to about 8 characters (and correspondingly more lines of length longer than that).

(That assessment is based on a single sample book, in English, with a text-indent of 1em. The sampling also omits paragraphs shorter than 3 lines, on grounds that changes to very short paragraphs aren't necessarily improvements, so including such changes in statistics makes it a noisier measure of improvement.)

Early releases of Prince for Books had a higher degree of avoidance of short last lines, but I've found that most published books (sampling mostly English books) have very little avoidance of short last lines other than lines shorter than the text-indent. (A few books do allow last lines shorter than text-indent, especially in Italian; and there are also books that avoid short last lines to a greater degree than Prince for Books currently does, including some (but not all) books from the Folio Society.)

Prince for Books doesn't currently use font-stretch or affine scaling of glyphs for justification, but does include subtle letter-spacing adjustment (and of course word spacing).

However, this applies essentially only to justified paragraphs: for paragraphs whose text-align is not 'justify', the only tweaks that Prince for Books makes compared to normal Prince is occasionally bringing a short word at the end of a longish line down to the next line. With the same book & styling other than setting ragged, I do see a 21% reduction in frequency of last lines shorter than 6 characters [again not counting very short paragraphs], but essentially no change in frequency of last lines of 6–8 characters.