by raphlinus · 3y ago · 0 comments
This is not conceptually a difficult problem, you can just shape all possible substrings between candidate line breaks to get their widths, at which point Knuth-Plass will give the optimal line breaks (relative to your objective function). But given that shaping is expensive, you really want to avoid that in the 99.99% or so cases where the width of the word isn't altered by other words beyond space boundaries. That's what the "safe to break" logic is about - letting you know when you can make that assumption, as opposed to needing to reshape to get the precise metrics.
[1]: https://en.wikipedia.org/wiki/Nastaliq#/media/File:Khatt-e_N...
That said, logos are a good example where TeX is not suited. Odds are high that it will not help stack words in a way that works for slogans and such.
Also, the original HTML tables algorithm was evidently meant for hardcopy output and not relayout-upon-typed-input, as it was horrendously slow without making some safe to break optimisations.