GRN(1) | General Commands Manual | GRN(1) |
grn - groff preprocessor for gremlin files
grn |
[-Cv] [-T dev] [-M dir] [-F dir] [file ...] |
grn is a preprocessor for including gremlin pictures in groff input. grn writes to standard output, processing only input lines between two that start with .GS and .GE. Those lines must contain grn commands (see below). These commands request a gremlin file, and the picture in that file is converted and placed in the troff input stream. The .GS request may be followed by a C, L, or R to center, left, or right justify the whole gremlin picture (default justification is center). If no file is mentioned, the standard input is read. At the end of the picture, the position on the page is the bottom of the gremlin picture. If the grn entry is ended with .GF instead of .GE, the position is left at the top of the picture.
Please note that currently only the -me macro package has support for .GS, .GE, and .GF.
Whitespace is permitted between a command-line option and its argument.
Each input line between .GS and .GE may have one grn command. Commands consist of one or two strings separated by white space, the first string being the command and the second its operand. Commands may be upper or lower case and abbreviated down to one character.
Commands that affect a picture's environment (those listed before default, see below) are only in effect for the current picture: The environment is reinitialized to the defaults at the start of the next picture. The commands are as follows:
Since grn is a preprocessor, it doesn't know about current indents, point sizes, margins, number registers, etc. Consequently, no troff input can be placed between the .GS and .GE requests. However, gremlin text is now processed by troff, so anything valid in a single line of troff input is valid in a line of gremlin text (barring ‘.’ directives at the beginning of a line). Thus, it is possible to have equations within a gremlin figure by including in the gremlin file eqn expressions enclosed by previously defined delimiters (e.g. $$).
When using grn along with other preprocessors, it is best to run tbl before grn, pic, and/or ideal to avoid overworking tbl. Eqn should always be run last.
A picture is considered an entity, but that doesn't stop troff from trying to break it up if it falls off the end of a page. Placing the picture between ‘keeps’ in -me macros will ensure proper placement.
grn uses troff's number registers g1 through g9 and sets registers g1 and g2 to the width and height of the gremlin figure (in device units) before entering the .GS request (this is for those who want to rewrite these macros).
There exist two distinct gremlin file formats, the original format from the AED graphic terminal version, and the SUN or X11 version. An extension to the SUN/X11 version allowing reference points with negative coordinates is not compatible with the AED version. As long as a gremlin file does not contain negative coordinates, either format will be read correctly by either version of gremlin or grn. The other difference from SUN/X11 format is the use of names for picture objects (e.g., POLYGON, CURVE) instead of numbers. Files representing the same picture are shown in Table 1 in each format.
sungremlinfile | gremlinfile | |
0 240.00 128.00 | 0 240.00 128.00 | |
CENTCENT | 2 | |
240.00 128.00 | 240.00 128.00 | |
185.00 120.00 | 185.00 120.00 | |
240.00 120.00 | 240.00 120.00 | |
296.00 120.00 | 296.00 120.00 | |
* | -1.00 -1.00 | |
2 3 | 2 3 | |
10 A Triangle | 10 A Triangle | |
POLYGON | 6 | |
224.00 416.00 | 224.00 416.00 | |
96.00 160.00 | 96.00 160.00 | |
384.00 160.00 | 384.00 160.00 | |
* | -1.00 -1.00 | |
5 1 | 5 1 | |
0 | 0 | |
-1 | -1 | |
Table 1. File examples |
gremlin File Format − Object Type Specification | ||
AED Number | SUN/X11 Name | Description |
0 | BOTLEFT | bottom-left-justified text |
1 | BOTRIGHT | bottom-right-justified text |
2 | CENTCENT | center-justified text |
3 | VECTOR | vector |
4 | ARC | arc |
5 | CURVE | curve |
6 | POLYGON | polygon |
7 | BSPLINE | b-spline |
8 | BEZIER | Bézier |
10 | TOPLEFT | top-left-justified text |
11 | TOPCENT | top-center-justified text |
12 | TOPRIGHT | top-right-justified text |
13 | CENTLEFT | left-center-justified text |
14 | CENTRIGHT | right-center-justified text |
15 | BOTCENT | bottom-center-justified text |
Table 2. | ||
Type Specifications in gremlin Files |
1 − | thin dotted lines | |
2 − | thin dot-dashed lines | |
3 − | thick solid lines | |
4 − | thin dashed lines | |
5 − | thin solid lines | |
6 − | medium solid lines |
For polygons, one more value, 0, is valid. It specifies a polygon with an invisible border. For text, the brush selects a font as follows:
1 − | roman (R font in groff) | |
2 − | italics (I font in groff) | |
3 − | bold (B font in groff) | |
4 − | special (S font in groff) |
If you're using grn to run your pictures through groff, the font is really just a starting font: The text string can contain formatting sequences like “\fI” or “\d” which may change the font (as well as do many other things). For text, the size field is a decimal value between 1 and 4. It selects the size of the font in which the text will be drawn. For polygons, this size field is interpreted as a stipple number to fill the polygon with. The number is used to index into a stipple font at print time.
gremlin was designed for AEDs, and its coordinates reflect the AED coordinate space. For vertical pictures, x-values range 116 to 511, and y-values from 0 to 483. For horizontal pictures, x-values range from 0 to 511 and y-values range from 0 to 367. Although you needn't absolutely stick to this range, you'll get best results if you at least stay in this vicinity. Also, point lists are terminated by a point of (-1, -1), so you shouldn't ever use negative coordinates. gremlin writes out coordinates using format “%f1.2”; it's probably a good idea to use the same format if you want to modify the grn code.
There is no longer a restriction on the range of coordinates used to create objects in the SUN/X11 version of gremlin. However, files with negative coordinates will cause problems if displayed on the AED.
David Slattengren and Barry Roitblat wrote the original Berkeley grn. Daniel Senderowicz and Werner Lemberg modified it for groff.
7 March 2023 | groff 1.22.4 |