Troff Pic

Troff is a typesetting system for unix. It is one of the oldest pieces of unix software. Part of troff is a graphics subsystem, called pic, which defines a picture language and provides software to typeset them.

Despite its heritage and the arcanity of the documentation, Troff Pic is really quite easy to use. For example, here's a diagram of two labelled boxes, connected by an arrow (look at the source of the page to see where the line breaks are):

box "First Box" arrow box "Second Box"

The output of this is at <> (sizing isn't quite sorted out yet).


The Twic I Wishlist includes a wish for Twic I to support Wiki Diagrams; Troff Pic might be a way to do it. The huge problem with Troff Pic is that it has a construct which allows arbitrary shell commands to be executed, which really, really isn't okay in this context. If it can't be disabled at the back end, the input would have to be pre-filtered by Twic I, which would be really hard.

This command line (as a filter) seems to convert pic into PNG quite well (on urchin, under groff 1.17.2), although the resolution needs tweaking:

groff -p | gs -q -sDEVICE=png256 -sOutputFile='-' -dBATCH -dNOPAUSE -

To render Troff Pic diagrams, Twic I would just have to excise the text and feed it to this command, stuffing the output into a file somewhere (eg ~twic/wiki/pic/Troff Pic.1.png).

Category Geekery

Sun, 10 Nov 2002 14:50:38 GMT Front Page Recent Changes Message Of The Day