Re:Perfect Edition: A lightweight, responsive web e-book tem...
by pgcj_poster on Wednesday July 29, 2020 @02:22PM
(#23989950)
I think text-justify is fine as long as the text width is somewhat wide (>72 characters) and it's inside a @supports(hyphens: auto). It's not as nice as TeX, but it's fast and Good Enough.
Re:Perfect Edition: A lightweight, responsive web e-book tem...
by cosmojg on Tuesday July 28, 2020 @05:37PM
(#23980972)
Are there any implementations of Knuth-Plass line breaking in HTML or CSS libraries? Maybe in a static site generator?
Re:Perfect Edition: A lightweight, responsive web e-book tem...
by mpetroff on Tuesday July 28, 2020 @06:11PM
(#23981235)
It's possible, but the markup is very, very messy. I made a proof-of-concept by hand a couple months ago [1], but it would require quite a bit more work to automate it. It's probably best to just wait for browsers to implement CSS Text Module Level 4, which includes a property for enabling use of better line breaking algorithms.
[1] https://mpetroff.net/files/pre-calculated-line-breaks-demo/
Anyway, in all current browsers, `text-align: justify` does greedy text layout, where it fits as many words in each line as it can before wrapping. This is technically trivial, but visually inferior to Knuth-Plass line breaking, which tries to find the most visually-pleasing place to break lines. Look at the screenshots of https://github.com/robertknight/tex-linebreak to see the difference. It can be rather stark.