[looping TUHS back in since I'm correcting a message I sent there]

Hi Dave,

At 2025-05-06T08:36:55-0500, Dave Kemper wrote:
> On Fri, May 2, 2025 at 7:35 PM G. Branden Robinson
> <g.branden.robin...@gmail.com> wrote:
> > I guess another way of saying this is that, as I conceive it, a line
> > that is "adequately full" contributes to the page's uniformity of
> > grayness by definition.
> 
> For an example of less-than-ideal results if this is _not_ considered
> the case (groff's behavior before this change), see
> http://savannah.gnu.org/bugs/?60673#comment0 (the initial report that
> precipitated the commit Doug is commenting on).

Yes.  In my reply to Doug I incorrectly characterized the resolution of
this bug as a "2023" change of mine, but I actually landed the change in
2021.  It simply took until 2023 to appear in a released _groff_.

To make this message more TUHS-o-riffic, let's observe that input using
DWB 3.3 troff and Heirloom Doctools troff (descended from Solaris troff,
descended from DWB 2.0 troff [I think]), and both of which descend from
Kernighan's device-independent troff circa 1980.

$ DWBHOME=. ./bin/nroff groff-60673.roff | cat -s
While the example in bug  57836's  original  report  is  somewhat
contrived and a bit of an edge case in real life, there turns out
to be a more innate  bug  in  grotty's  balancing  algorithm.  As
mentioned before (and easily observable), when grotty adds spaces
to a line in the process  of  justifying  it,  the  algorithm  it
utilizes adds spaces from opposite ends of each line. But when it
adds this space, it does not take  into  account  lines  with  no
adjustment at all required. Therefore if space only need be added
to every other line of the text, all  the  space  ends  up  being
added to the same end of the line, degrading the uniform grayness
of the output, as can be seen  in  this  example.  There  is  one
fairly simple way to address this: grotty shouldn't "count" lines
that don't need to be adjusted;  instead,  it  should  apply  the
alternation pattern only to those lines that do need adjustment.

$ ./bin/nroff groff-60673.roff | cat -s
While the example in bug  57836's  original  report  is  somewhat
contrived and a bit of an edge case in real life, there turns out
to be a more innate  bug  in  grotty's  balancing  algorithm.  As
mentioned before (and easily observable), when grotty adds spaces
to a line in the process  of  justifying  it,  the  algorithm  it
utilizes adds spaces from opposite ends of each line. But when it
adds this space, it does not take  into  account  lines  with  no
adjustment at all required. Therefore if space only need be added
to every other line of the text, all  the  space  ends  up  being
added to the same end of the line, degrading the uniform grayness
of the output, as can be seen  in  this  example.  There  is  one
fairly simple way to address this: grotty shouldn't "count" lines
that don't need to be adjusted;  instead,  it  should  apply  the
alternation pattern only to those lines that do need adjustment.

They are the same, and differ from groff 1.22.4 and earlier only in that
they adjust spaces starting from the right end of the line instead of
the left.

At the risk of tooting our own horn, here's how groff 1.23.0+ handles
the same input.

$ ~/groff-1.23.0/bin/nroff groff-60673.roff | cat -s
While  the  example  in  bug  57836’s original report is somewhat
contrived and a bit of an edge case in real life, there turns out
to be a more innate  bug  in  grotty’s  balancing  algorithm.  As
mentioned before (and easily observable), when grotty adds spaces
to  a  line  in  the  process  of justifying it, the algorithm it
utilizes adds spaces from opposite ends of each line. But when it
adds this space, it does not take  into  account  lines  with  no
adjustment at all required. Therefore if space only need be added
to  every  other  line  of  the text, all the space ends up being
added to the same end of the line, degrading the uniform grayness
of the output, as can be seen  in  this  example.  There  is  one
fairly simple way to address this: grotty shouldn’t "count" lines
that  don’t  need  to  be  adjusted; instead, it should apply the
alternation pattern only to those lines that do need adjustment.

Three observations:

1.  One can find the input at Dave's URL above.
2.  The input disables inter-sentence spacing.
3.  The adjustment algorithm is a property not of grotty(1) (the output
    driver), but of GNU troff itself.

Regards,
Branden

Attachment: signature.asc
Description: PGP signature

Reply via email to