[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] grotty and \D'l 0 0'
From: |
Werner LEMBERG |
Subject: |
Re: [Groff] grotty and \D'l 0 0' |
Date: |
Sat, 01 Dec 2007 00:57:31 +0100 (CET) |
> > Using grotty, this code
> >
> > x \D'l 1m 0' x
> >
> > x \D'l 0 1v' x
> >
> > produces
> >
> > x --x
> >
> > x |
> > |x
> >
> > [You have to use the current CVS or version 1.19.0 and earlier -- the
> > versions inbetween handle this incorrectly.]
>
> My old and crufty 1.18.1 on slightly different input produces
>
> $ cat w.tr
> X
> .br
> X\D'l 1m 0'X
> X\D'l 0 1v'X
> $ groff -Tutf8 w.tr | cat -s
> X
> X-X X|
> X
>
> $
Exactly. groff treats a two-cell line having a one-cell width.
Closer inspection would show that e.g.
X\D'l 1m 0'X
is translated to
X--^HX
> > As can be seen, a line of length 1m (1v) is drawn as *two*
> > character cells, not one, but still takes only a length (height)
> > of one character cell. This result may be surprising but it is
> > the correct one so that it is completely analogous to the output
> > of other devices -- it took a long time until I came to this
> > conclusion :-)
>
> I can believe it took a long time. I puzzled over a pixel drawing
> problem once for ages not knowing that accepted practice had already
> worked out the "right way". However, I'm not sure your output
> above, or mine, is the "right" result. :-)
Both are right. You've obviously missed the `^H' backspace control
character.
> Looking at the PostScript output of w.tr, I think this is a better
> approximation.
>
> X
> X_X X
> |X
>
> The horizontal line should be the baseline of the text,
Using `_' instead of `-' is not a good idea. Just compare
+____+ +----+
| | versus | |
+____+ +----+
> and only one character long because we assume a fixed-width font.
This is a wrong assumption.
> I suppose you're thinking of an em-dash being represented by two --
> characters in plain text so a 1m line should be two characters too.
No, this isn't the reason. Consider this example:
foo
.sp -1
\D'l 0 1v'
.sp -1
\h'3m'\D'l 0 1v'
.br
\D'l 3m 0'
bar
which results in
foo
| |
+--+
bar
Now imagine that \D'l 3m 0' is only three character cells long, and
\D'l 0 1v' only a single one. You would get
foo
| |
---
bar
Which is not acceptable, I think. We have to consider both line
lengths and line positions.
BTW, the current behaviour of grotty is fine for must purposes, exept
for single-line tables with vertical lines as field separators...
> > x \D'l .1m 0' x
> >
> > x \D'l 0 .1v' x
> >
> > produces
> >
> > x +x
> >
> > x +x
> >
> > The line lengths are rounded to the next multiple of the
> > horizontal and vertical device resolution, which is 0 here in both
> > directions -- the line more or less degenerates to a dot,
> > represented with `+'.
>
> Previous groffs, e.g. 1.18.1, used to do this though?
AFAIK, it was never possible with GNU troff to produce a single-cell
line in TTY output with \D'l...'.
Werner