hn.today

A page looks innocent: the algorithms behind a typeset page

news.speedata.de3 points0 comments
Screenshot of A page looks innocent: the algorithms behind a typeset page

Explains the algorithms and implementation choices behind a well-typeset page by walking from the page level down to PDF bytes and comparing two engines: speedata Publisher (which delegates most typographic work to LuaTeX) and boxes and glue (a modular Go library). The biggest practical difference is architecture: Publisher uses LuaTeX’s page builder and callbacks or its own page model with grids and explicit areas, while boxes and glue splits functionality into replaceable Go packages. Concrete layout challenges are highlighted - page assignment, widows and orphans, multi-page tables, floats - and footnotes are shown as especially tricky because they must stay with their reference; LuaTeX uses insertions, whereas htmlbag in boxes and glue ties a footnote to its line (splitting long footnotes across pages is not yet implemented there).

Details of line breaking, hyphenation and shaping are covered with specifics: Knuth-Plass line-breaking finds globally optimal breaks by minimizing demerits (demonstrated with a break-graph and interactive demo), font expansion and hanging punctuation improve optical results, Liang’s pattern-based hyphenation chooses breakable gaps via numeric pattern wins, and shaping (ligatures, kerning, contextual forms, bidi, reordering) uses OpenType GSUB/GPOS via HarfBuzz (LuaTeX) or a Go port (textshape). The pipeline ends with PDF backends (LuaTeX backend or baseline-pdf), and examples/debug output show how parameters affect outcomes.

Read on news.speedata.de0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.