A page is
a constraint.

Swiss grid systems compiled into executable rules, so that layouts can be counted, scored, sampled, and re-rolled. Gerstner's programmes and Müller-Brockmann's modular grid, read as a specification.

0 runtime dependencies 104 tests 0.013 px worst baseline deviation MIT

The name. Das Geviert is German for the em quad: the square blank of type metal, exactly as wide as the face is tall, from the old verb vieren, to make four. Pronounced geh-FEERT, IPA [ɡəˈfiːɐt].

A spread from THE GEVIERT MANUAL: two facing A4 pages with plates on the modular grid.
A spread from the manual, composed by the library from seed manual-1.

01  The demonstration

The manual composes itself, in your browser.

The Geviert Manual is the library's account of itself, at book length: ten chapters of specification, plates that are real pages from the books it has set, the complete public API in monospace, and the test suite by name. About 95 pages, composed from a manuscript, a plate list, and a seed in a few hundred milliseconds. Read it live → or take the printed PDF.

02  The argument

Instead of solutions for problems, programmes for solutions.

That is Gerstner, in 1964, and it is the whole API. You do not author a layout. You author the constraints a layout must satisfy, and the library enumerates the ones that do, scores them by rules taken from the books, and lets a seed choose. The same seed returns the same page, forever.

Every typesetting engine can set a beautiful line. TeX has done it since 1981, and this library borrows its algorithm without apology. What no typesetter does is treat the grid as the primitive.

There is no way to express an off-grid position.

Which sounds like a cage and turns out to be a door. Because the set of legal pages is finite, layout stops being a matter of nudging boxes and becomes a search. The rules decide which pages are permitted. Taste, a small object of named weights, decides which permitted page is good.

Each rule has a page number, and each idea has a demo you can hold.

03  The shape of it

Give it words, pictures, a grid, and a seed.

npm install geviert
// Any real font, one call (optional peer: opentype.js)
await registerFontFile('inter', './Inter-Regular.ttf');

// The register: refuses illegal line heights, and names the legal ones
const T = typeSystem({ module: 12, roles: { body, chapter, caption } }).roles;

const pages = composeDocument({
  grid: ({ side }) => grid({ page: 'A4', margins, columns: 4,
                             line: T.body.lineHeight, rows: 8, side }),
  styles: T,
  story: [{ text: 'ONE', role: 'chapter', rule: true }, ...paragraphs],
  figures: [
    { anchor: '(Plate 3)', sizes: [{ cols: 2, rows: 3 }], href, caption },
    { anchor: '(Chart 1)', sizes: [{ cols: 2, rows: 3 }],
      chart: { data } },       // bars are WHOLE TEXT LINES, by law
  ],
  paragraphDevice: 'indent',   // or 'line'; MB p.34 names both
  bodyAlign: 'justify',        // grid-aware Knuth–Plass
  seed: 'a-seed',              // same seed, same book, forever
}).pages;

renderDOM(pages[0], el);          // live text on the baseline grid
renderPage(pages[0]);             // or SVG, or print-ready PDF

Fully typed. Zero runtime dependencies. Composes ~30 pages a second on an ordinary laptop. MIT, on GitHub.