The web is now twenty and browsers are still incapable of something as basic and commonplace as hyphenation and justification. It’s a real shame that this problem has to be solved with JavaScript in 2010. How old is TeX again?
I've been asking for years why browsers do not have this. The only reply I've gotten is for performance considerations, which is a bad answer for several reasons.
Knuth and Plass line breaking algorithm in JavaScript
21–30 of 44 posts
Re: Knuth and Plass line breaking algorithm in JavaScript
#22Earlier quoted context omitted.
I've been asking for years why browsers do not have this. The only reply I've gotten is for performance considerations, which is a bad answer for several reasons.
Internet Explorer actually has this through the (almost standardized) text-justify CSS property. It still doesn't do hyphenation, but Hyphenator.js ( http://code.google.com/p/hyphenator/ ) fills that gap pretty nicely. Performance isn't a good argument in my opinion. The algorithm isn't that expensive. The most expensive part right now is retrieving all the text metrics, but you would get that a lot cheaper in the br…
Re: Knuth and Plass line breaking algorithm in JavaScript
#23Re: Knuth and Plass line breaking algorithm in JavaScript
#24Earlier quoted context omitted.
I've been asking for years why browsers do not have this. The only reply I've gotten is for performance considerations, which is a bad answer for several reasons.
Another reason I've heard before was internationalization. Not sure how many languages have draconian hyphenation rules like English though.
Re: Knuth and Plass line breaking algorithm in JavaScript
#25Re: Knuth and Plass line breaking algorithm in JavaScript
#26Earlier quoted context omitted.
Another reason I've heard before was internationalization. Not sure how many languages have draconian hyphenation rules like English though.
English hyphenation rules are very simple and relaxed by continental standards. It is about the only language where such a simple and straightforward algorithm as the one in TeX (it doesn't even contain a full list of word stems and a rule engine for the (de)construction of composite words) can work.
Really? From my experience, ESL students often don't understand the logic behind english syllables.
My point though, is that if different languages hyphenate differently and we're talking about sites with international user generated content (Facebook or Orkut come to mind), then it's not exactly trivial to hyphenate correctly.
Re: Knuth and Plass line breaking algorithm in JavaScript
#27Earlier quoted context omitted.
English hyphenation rules are very simple and relaxed by continental standards. It is about the only language where such a simple and straightforward algorithm as the one in TeX (it doesn't even contain a full list of word stems and a rule engine for the (de)construction of composite words) can work.
>> English hyphenation rules are very simple and relaxed by continental standards. Really? From my experience, ESL students often don't understand the logic behind english syllables. My point though, is that if different languages hyphenate differently and we're talking about sites with international user generated content (Facebook or Orkut come to mind), then it's not exactly trivial to hyphenate correctly.
Re: Knuth and Plass line breaking algorithm in JavaScript
#28Earlier quoted context omitted.
I've been asking for years why browsers do not have this. The only reply I've gotten is for performance considerations, which is a bad answer for several reasons.
Internet Explorer actually has this through the (almost standardized) text-justify CSS property. It still doesn't do hyphenation, but Hyphenator.js ( http://code.google.com/p/hyphenator/ ) fills that gap pretty nicely. Performance isn't a good argument in my opinion. The algorithm isn't that expensive. The most expensive part right now is retrieving all the text metrics, but you would get that a lot cheaper in the br…
I suspect that if you take it in pieces: first get a decent hyphenation algo into Pango, then get that into FF and WebKit, then work on the line-breaker, and then get a new CSS rule approved by the W3C... well, maybe you could get it done in 3 or 4 years.
Re: Knuth and Plass line breaking algorithm in JavaScript
#29Also: It blows up in IE9 for me though, many of the lines go on for quite a ways.
Re: Knuth and Plass line breaking algorithm in JavaScript
#30Earlier quoted context omitted.
Internet Explorer actually has this through the (almost standardized) text-justify CSS property. It still doesn't do hyphenation, but Hyphenator.js ( http://code.google.com/p/hyphenator/ ) fills that gap pretty nicely. Performance isn't a good argument in my opinion. The algorithm isn't that expensive. The most expensive part right now is retrieving all the text metrics, but you would get that a lot cheaper in the br…
I also looked into it recently, and Damon from the Gnome project attempted it in 2002 or so. Also Adobe+Google are trying to get it into WebKit. The problem (as far as I can tell) is that people have tried to do it all at once, and pushing such a large thunk of code upstream is very hard. I suspect that if you take it in pieces: first get a decent hyphenation algo into Pango, then get that into FF and WebKit, then wo…