groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] "Cosmetic" filling


From: Ted Harding
Subject: Re: [Groff] "Cosmetic" filling
Date: Tue, 05 Sep 2006 19:20:49 +0100 (BST)

On 03-Sep-06 Gunnar Ritter wrote:
> Werner LEMBERG <address@hidden> wrote:
> 
>> I haven't found out yet the cause of this behaviour; I invite you to
>> use a debugger so that you can find the relevant spot. :-)
> 
> The problem is in environment::do_break() after the comment
> "this is so that hyphenation works". A zero-length space is
> added, so line->width() is zero when possibly_break_line()
> gets called, and the length of a real space at the end of
> the line is not subtracted from width_total anymore when
> considering whether to spread the line.
> 
> Adding the zero-length space only if line->nspaces() == 0
> looks like a possible fix to me.
> 
> Test input:
> 
> .ds a \ \h'-1u'
> .ll \w'some\*a text and a \(br'u
> some\*a text and a \(br
> some text and a \(br
> 
> (The box rules should not align.)
> 
>       Gunnar

That's an interesting comment. I've tried tracing the consequences
in the source code, but got lost!

To follow up on the observation that prompted my original post.
I've done an experiment.

The line that seemed to stretch out to fill the full line-width
ended (in the troff source):

... (Hampshire Record Society, 1889 ff.)

My original test, to ensure that it really did fill the line,
compared it with a copy immediately below (separated by ".br")
ending in:

... (Hampshire Record Society, 1889 ff.)
.br
... (Hampshire Record Society, 1889 ff.)\p

so that the "\p" would force the second copy to expand. I found
that the vertical positions of the final ")" were identical.

It remained to test that the fill was not simply a coincidence.
So I planted a leftwards horizontal shift in the first copy,
(in devps units, so pt/1000) like:

... (Hampshire Record Society, 1\h'-1000u'889 ff.)
.br
... (Hampshire Record Society, 1889 ff.)\p

This backspaced the "8" somewhat over the "1", slightly increased
the intewrord spacing, and resulted in the final ")" still being
exactly aligned with the second copy.

I could increase the backwards shift up to:

... (Hampshire Record Society, 1\h'-1235u'889 ff.)
.br
... (Hampshire Record Society, 1889 ff.)\p

and still have the first line stretch to exactly fill the
linelength. So it was not a coincidence!

However, when I increased the left-shift from 1235u to 1236u, it
then did not stretch the line.

Then I worked the other way, using a right-shift. I could get
up to:

... (Hampshire Record Society, 1\h'4264u'889 ff.)
.br
... (Hampshire Record Society, 1889 ff.)\p

before the ".ffp)" at the end was forced onto the next line,
which happened at 4265u.

Now, 1235u + 4265u = 5500u, or 5.5p; and I am working with 11pt
text, so the range over which I can vary the unstretched line
length is pointsize/2 (or 0.5m). And, for what it is worth, I'm
using the defaults for \n[.ss] and \n[.sss], namely 12/36m.

0.5m is not a big margin. However, it is not clear why this is
the critical value. (Also, there are 9 stretchable spaces in
the line.)

One possibility is that if the output line, unstretched, is within
X (= 0.5m?) of the full linelength, then it will be stretched;
otherwise not.

Another is that if the stretching would make the inter-word spacing
greater than Y, then it will not be stretched.

It may be a combination of two conditions:
If the unstretched line is within X of the linelength, and the
inter-word spacing if it is stretched to fill is not greater than Y,
then it will be stretched to fill. Otherwise not.

I'm inclined to suspect the first.

Again, I'm too lost in the source code when it comes to trying
to trace this sort of thing to be able to track it down!

Again, comments welcome!

(And I'd like to reiterate that I regard this behaviour, up to
a point, as desirable. Certainly in a paragraph, if the last line
is almost as long as the full line, then it will look better if
stretched to fill, so that you don't get a nasty little notch at
the bottom right-hand corner. But I'd like to have some control
over the value -- of X -- at which it happens!)

Best wishes to all,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 05-Sep-06                                       Time: 19:20:45
------------------------------ XFMail ------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]