n-t-roff / heirloom-doctools

The Heirloom Documentation Tools: troff, nroff, and related utilities
http://n-t-roff.github.io/heirloom/doctools.html
Other
127 stars 23 forks source link

pic half-fills filled boxes; workaround included #117

Open tnalpgge opened 1 year ago

tnalpgge commented 1 year ago

The minimal input for reproducing the problem:

.PS
box fill
.PE
#!/bin/sh
PATH=/usr/local/heirloom/bin:${PATH}
printf ".PS\nbox fill\n.PE\n" | pic | troff | dpost >boxfill.ps
convert -crop 72x60+64+0 boxfill.ps boxfill.png

(Note to self: learn page control so I can eliminate convert -crop. Suggestions welcome!)

Observation: lower right-hand side of box is filled.

boxfill

Workaround:

#!/usr/bin/env awk -f
/^\/inpath true def/ { inpath = 1; dl = 0 }
/^\/inpath false def/ { inpath = 0 }
inpath && ($5 == "Dl") { dl++ }
inpath && (dl == 2) { print $3, $4, $1, $2, $5; next }
{ print } 

This exchanges the order of the coordinates in the second segment of the path, to convince the eofill operator to do the right thing.

awk -f fillboxfix.awk boxfill.ps >fillboxfix.ps
convert -crop 72x60+64+0 fillboxfix.ps fillboxfix.png

Now the entire box should be filled.

fillboxfix

I'm not expecting a fix any time soon, but I'm leaving a workaround here in case anyone else finds it useful. I tried digging into the output of pic(1) (before feeding it to troff(1)) but got somewhat lost in the sequence of moves and draws that produced the box. The Postscript was easier to process with existing tools for a workaround.

I observed this on FreeBSD 13.2-RELEASE, with Heirloom doctools installed via pkg(8).

$ /usr/local/heirloom/bin/troff -V
Heirloom doctools troff, release 191015
$ cat /etc/os-release
NAME=FreeBSD
VERSION="13.2-RELEASE"
VERSION_ID="13.2"
ID=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="FreeBSD 13.2-RELEASE"
CPE_NAME="cpe:/o:freebsd:freebsd:13.2"
HOME_URL="https://FreeBSD.org/"
BUG_REPORT_URL="https://bugs.FreeBSD.org/"
$ uname -a
FreeBSD [REDACTED] 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC amd64
$ pkg info -ix heirloom
heirloom-doctools-191015

Heirloom doctools has been a pleasure to use. Thank you maintainers for making it easy to produce beautiful documents that play nicely with revision control systems and grep :smile: