5 ms·
Are those hyphenation algorithms really that hard to implement? Yes: see (for example) http://en.wikipedia.org/wiki/Hz-program http://en.wikipedia.org/wiki/Hz-
by celoyd 16y ago
Are those hyphenation algorithms really that hard to implement?
Yes: see (for example) http://en.wikipedia.org/wiki/Hz-program http://en.wikipedia.org/wiki/Hz-program .
A really good H&J algorithm is doing a significant amount of work. It has to think about things like successive hyphens (which get distracting quickly), rivers (the unpleasant vertical lines of whitespace that appear especially in over-spaced text), and so on. This involves lots of backtracking and image processing, and it fires every time the layout changes. It’s all possible to do in a browser someday, but it’s not trivial.
- deleted 16y ago[deleted]
- DennisP 16y agoTeX does a pretty good job with that stuff. Knuth gives a clear and concise explanation of the algorithm in a chapter of Digital Typography. I don't think you need to get too fancy with kerning and scaling, the way Hz does. It's a web page, not a printed book. Put the hyphens where they need to be to optimize each paragraph, and you'll probably get decent results. Knuth's algorithm will do that effectively and efficiently.