1 hour ago · 8 min read1683 words · Tech · hide

Good typography is difficult to achieve on the web. Compared to typesetting engines like LaTeX or Typst, the web still lacks a good line-breaking algorithm. The CSS directive text-wrap: pretty tries to improve the situation but is still not implemented in Firefox and produces eerie narrower paragraphs with Safari. Various good implementations of the Knuth-Plass algorithm exist in JavaScript, but they either reflow the text or delay its display. Instead, I taught my static site generator to manually insert soft hyphens and non-breaking spaces at tactical locations to achieve a predictable, okayish result. Comparison with existing solutions Implementation Dealing with HTML Faster with Cython Inline code Copy/paste Is it worth it? Comparison with existing solutions Let's benchmark with a short paragraph in French from Jules Verne's "L'Île mystérieuse": Le marin pressa la main du reporter, dont il ne pouvait se faire entendre, et d'une façon qui signifiait : « Attendez ! » puis, il rentra…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town