3 ms·
Does anyone know what the relationship is between Knuth/Plass (or similar pretty-line-wrapping algos, if others exist), and Unicode? I know Unicode has their o
by nfoz 8y ago
Does anyone know what the relationship is between Knuth/Plass (or similar pretty-line-wrapping algos, if others exist), and Unicode? I know Unicode has their own line-wrap algorithm, but is it possible to use both?
- svat 8y agoWhat Unicode calls the “Unicode line breaking algorithm” (http://unicode.org/reports/tr14/ http://unicode.org/reports/tr14/ see “LB1” to “LB31”) is a method of determining “break opportunities”, the places where it is allowed to break a line of Unicode text. What the Knuth-Plass paper (http://www.eprg.org/G53DOC/pdfs/knuth-plass-breaking.pdf http://www.eprg.org/G53DOC/pdfs/knuth-plass-breaking.pdf) is about is a method of determining, given a paragraph along with its “break opportunities”, a partition of the paragraph into lines such that (a certain function of) the stretching/shrinking of spaces on the lines is minimized. So yes they can be used together. In fact the Unicode TeX engines like XeTeX and LuaTeX do so (I don't know how well they follow the Unicode specification intrinsically versus with the support of language-specific packages, but they seem to do the job).
- nfoz 8y agoAwesome, thanks for the explanation!
- jahewson 8y agoYes, the Unicode line breaking algorithm tells you how to compute where breaks are permitted. But it’s up to you to choose which breaks to actually use. What’s tricky is actually OpenType, because the length of a “word” can vary in complex ways depending on whether or not it is broken - much more complex than simple hyphens.
- khaled 8y agoThat happens in TeX as well, the width of “efficient” does not necessarily equal to the width of “ef” + “ficient” due to the presence of ligatures, and TeX deals with it by storing the width of the full ligature as well as the pre and post-line break widths (for all possible line breaks in the middle of paragraphs) and takes them into consideration when calculating line breaks. This can be generalized to any situation where line breaking changes the width of a chunk of the text.