RE: [PHP-DEV] Re: Suggestion: Adding fmt like linebreak algorithm
| From: | Dominik Roettsches | Date: | Wed, 26 Dec 2001 02:22:02 +0000 |
| Subject: | RE: [PHP-DEV] Re: Suggestion: Adding fmt like linebreak algorithm | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-74995@lists.php.net to get a copy of this message | ||
elixer@erols.com (Sean R. Bright) schrieb in news:001301c18daf$df79f6f0
$e18e0418@cc230545b:
> Doesn't wordwrap() already handle this? Or am i missing something?
>
> Sean
wordwrap() does just a simple wordwrap searching for the first whitespace
backwards and breaking the line.
The formatting fmt does is near-optimal line-breaking according to the paper
published by Donald E. Knuth:
"Breaking Paragraphs into Lines", D.E. Knuth and M.F. Plass,
chapter 3 of _Digital Typography_, CSLI Lecture Notes #78.
It achieves a better result than first fit (backward first fit search) or
other simple search methods by making use of dynamic programming.
Another suggestion is to replace the wordwrap code by the algorithm of
Knuth.
I'm looking forward to read your replies,
Dominik