Text That Keeps to a Shape

A magazine page rarely holds text in plain rectangles: a pull quote sits in a corner of a column, a picture interrupts a paragraph, a badge is round. Done by hand, every line is measured and cut one by one, and the whole work starts again the day the text is translated or changes length.

Here the program states each shape and nothing else: a column with a note set into its top right-hand corner, a circle, and a six-sided shape with a picture box in its middle. The text is set line by line, each line only where the shape holds it whole, so no letter crosses an edge. Beside the note the lines stop eight points short of it; in the circle they lengthen towards the middle; where a line meets the picture box, it fills the stretch to the left of the box, then carries on to its right. The same page in seven languages, each running to its own number of lines.

What This Example Shows

  • A column of text that goes round a note.
  • A circle and a six-sided shape filled line by line.
  • Lines that carry on past a picture box.

The Source Code, Complete

Nothing is left out and nothing is simplified: this is the program exactly as it runs, for the developer who uses this library. The third is the description itself: a plain list of what the page has to say, which is what the service is sent.

Read the Rust source Read the Python source Read the JSON source

The Document Itself

Open the document in English Open the document in French Open the document in German Open the document in Spanish Open the document in Italian Open the document in Portuguese

Examples Near This One

Breaking an Overlong Word

A word longer than the column that holds it: the library leaves it whole, cuts it at the column's edge, or cuts it and closes the line on a hyphen.

Break Points After a Slash or a Hyphen

A justified column set four times: file paths and compounds running past the edge with no break points, wrapping where a break after a slash or a hyphen is allowed, then wherever their punctuation allows one, and last with no-break hyphens that keep each compound whole.

A Stack Laid out by Hand, One Box at a Time

A delivery slip poured into two boxes, the second taking up where the first stopped, and a poster whose picture no box can hold, each box saying what became of the stack in it.

Every example, by subject