Badges of one size, names of every length

A conference orders its badges weeks before it knows who is coming. The card is one size, and the guest list is not: two short words for one visitor, a double-barrelled surname and a middle name for the next. Pick a size that suits the longest name and the short ones sit lost in the middle of their cards; pick one that suits the short names and the long ones walk off the edge. The evening before the doors open, somebody is shortening names by hand.

Here the card decides. Each name is handed the exact box it has to live in and asked what size it fits at, on both counts at once: no line reaching past the sides, and the whole name ending above the bottom. The sizes come down a quarter of a point at a time and stop at the first one that holds, so a short name keeps the size the design chose and only a long one comes out smaller. The sheet prints under each badge the size it arrived at, and the last panel shows the one case worth knowing about: a luggage tag far too small for the name it carries, where a floor stops the shrinking and the printer decides what to do next.

What this example shows

  • Every box keeps its size; only the words inside it move.
  • A short name is set at the size the design chose, and only a long one comes out smaller.
  • A floor is given with the box: nothing is shrunk out of sight.

The code that writes it, in full

Whole programs, hundreds of lines long, for whoever writes your software.

Read the Rust source Read the Python source

The document itself

Open the document in English Open the document in French

Examples near this one

Soft hyphens and no-break spaces

A justified column set twice: the long words breaking at their soft hyphens with a hyphen shown, or left whole, and a figure a no-break space keeps together.

Break points after a slash or a hyphen

A justified column set twice: file paths and compounds running past the edge with no break points, then wrapping where a break after a slash or a hyphen is allowed.

A font behind the font

One line of statuses set twice: in a company font alone, where the marks it has no glyph for come out as empty boxes, then with a second font behind it that draws them.

Every example, by subject