grn(1)
π grn(1) π
okay bestie, this page is from the General Commands Manual, and itβs all about grn, the preprocessor that yeets Gremlin pictures into your groff docs. π
β¨ NAME β¨
grn β embed Gremlin images in groff documents
πΈ SYNOPSIS πΈ
grn [-C] [-T dev] [-M dir] [-F dir] [file ...]
grn -?
grn --help
grn -v
grn --version
π DESCRIPTION π
okay so grn is a preprocessor for including gremlin pictures in troff(1) input. It 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 macros request a gremlin file; the picture in that file is converted and placed in the troff input stream. .GS may be called with a C, L, or R argument to center, left-, or right-align the whole gremlin picture (the default is to 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. π¦
Currently only the me macro package has support for .GS, .GE, and .GF.
grn produces drawing escape sequences that use groff's color scheme extension (\D'F ...'), and thus may not work with other troffs. no cap, that part matters π
π¦ grn commands π¦
Each input line between .GS and .GE may have one grn command. Commands consist of one or two strings separated by whitespace, the first string being the command and the second its operand. Commands may be upper- or lowercase and abbreviated down to one character. iykyk, short and sweet β¨
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.
1 Nβ Set gremlin's text size number 1 toNpoints. The default is12.2 Nβ Set gremlin's text size number 2 toNpoints. The default is16.3 Nβ Set gremlin's text size number 3 toNpoints. The default is24.4 Nβ Set gremlin's text size number 4 toNpoints. The default is36.roman fβ Set the roman font to troff's fontf(either a name or number). The default isR.italics fβ Set the italics font to troff's fontf(either a name or number). The default isI.bold fβ Set the bold font to troff's fontf(either a name or number). The default isB.special fβ Set the special font to troff's fontf(either a name or number). The default isS.l f,stipple fβ Set the stipple font to troff's stipple fontf(name or number). The commandstipplemay be abbreviated down as far as βstβ (to avoid confusion with βspecialβ). There is no default for stipples (unless one is set by the βdefaultβ command), and it is invalid to include a gremlin picture with polygons without specifying a stipple font. β οΈx N,scale Nβ Magnify the picture (in addition to any default magnification) byN, a floating-point number larger than zero. The commandscalemay be abbreviated down to βscβ.narrow N,medium N,thick Nβ Set the thickness of gremlin's narrow (medium and thick, respectively) lines toNtimes0.15pt(this value can be changed at compile time). The default is1.0(3.0and5.0, respectively), which corresponds to0.15pt(0.45ptand0.75pt, respectively). A thickness value of zero selects the smallest available line thickness. Negative values cause the line thickness to be proportional to the current point size.pointscale [off|on]β Scale text to match the picture. Gremlin text is usually printed in the point size specified with the commands1,2,3, or4, regardless of any scaling factors in the picture. Settingpointscalewill cause the point sizes to scale with the picture (within troff's limitations, of course). An operand of anything butoffwill turn text scaling on.defaultβ Reset the picture environment defaults to the settings in the current picture. This is meant to be used as a global parameter setting mechanism at the beginning of the troff input, but can be used at any time to reset the default settings.width Nβ Force the picture to beNinches wide. This overrides any scaling factors present in the same picture. βwidth 0β is ignored.height Nβ Force the picture to beNinches high, overriding other scaling factors. If bothwidthandheightare specified, the tighter constraint will determine the scale of the picture.heightandwidthcommands are not saved with a βdefaultβ command. They will, however, affect point size scaling if that option is set.file nameβ Get picture from gremlin filenamelocated the current directory (or in the library directory; see the-Moption above). If multiplefilecommands are given, the last one controls. Ifnamedoesn't exist, an error message is reported and processing continues from the.GEline.
π Usage with groff π
Since grn is a preprocessor, it has no access to elements of formatter state, such as indentation, line length, type size, or register values. Consequently, no troff input can be placed between the .GS and .GE macros. However, gremlin text elements are subsequently processed by troff, so anything valid in a single line of troff input is valid in a line of gremlin text (barring the dot control character β.β 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., β$$β). thatβs lowkey iconic π§
When using grn along with other preprocessors, run tbl(1) before grn, pic(1), and/or ideal. If eqn(1) is needed, run it as the last preprocessor. groff(1) automatically runs preprocessors in the correct order. order matters, bestie π
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 the me macros will ensure proper placement.
grn uses troff's 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 macro (this is for those who want to rewrite these macros).
π Gremlin file format π
There exist two distinct gremlin file formats: the original format for AED graphic terminals, and the Sun or X11 version. An extension used by 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 in 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 below. π
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
- The first line of each gremlin file contains either the string β
gremlinfileβ (AED) or βsungremlinfileβ (Sun/X11). - The second line of the file contains an orientation and x and y values for a positioning point, separated by spaces. The orientation, either
0or1, is ignored by the Sun/X11 version.0means that gremlin will display things in horizontal format (a drawing area wider than it is tall, with a menu across the top).1means that gremlin will display things in vertical format (a drawing area taller than it is wide, with a menu on the left side). x and y are floating-point values giving a positioning point to be used when this file is read into another file. The stuff on this line really isn't all that important; a value of β1 0.00 0.00β is suggested. - The rest of the file consists of zero or more element specifications. After the last element specification is a line containing the string β
-1β. - Lines longer than 127 characters are truncated to that length.
π Element specifications π
- The first line of each element contains a single decimal number giving the type of the element (AED) or its name (Sun/X11).
π gremlin File Format: Object Type Specification π
Hereβs the AED Number β Sun/X11 Name β Description mapping:
0/BOTLEFTβ text aligned to bottom left1/BOTRIGHTβ text aligned to bottom right2/CENTCENTβ center object3/VECTORβ vector4/ARCβ arc5/CURVEβ curve6/POLYGONβ polygon7/BSPLINEβ b-spline8/BEZIERβ BΓ©zier10/TOPLEFTβ text aligned to top left11/TOPCENTβ text aligned to top center12/TOPRIGHTβ text aligned to top right13/CENTLEFTβ text aligned to center left14/CENTRIGHTβ text aligned to center right15/BOTCENTβ text aligned to bottom center- Each line after the object type specifies a point used to display the element. It contains an x and a y coordinate in floating-point format, separated by spaces. The list of points is terminated by a line containing the string β
-1.0 -1.0β (AED) or a single asterisk, β*β (Sun/X11). - After the points comes a line containing two decimal values, giving the brush and size for the element. The brush determines the style in which things are drawn. For vectors, arcs, and curves there are six valid brush values. π₯
1β thin dotted lines2β thin dot-dashed lines3β thick solid lines4β thin dashed lines5β thin solid lines6β medium solid lines- π«Ά and hey,
0is a whole valid mood for polygons too β it literally just means "invisible border". No cap. For text, tho, that brush field picks you a font, like:- roman (R font in
troff) - italics (I font in
troff) - bold (B font in
troff) - special (S font in
troff)
- roman (R font in
- β¨ So if you're using
grnto run your pics throughgroff, the font is really just a starting font, okay? The text string can carry formatting sequences like\fIor\dwhich may change the font (and also do a whole bunch of other things, she's versatile π ). - For text, the size field is a decimal value between
1and4. It picks the size of the font the text gets drawn in. For polygons, that same size field gets interpreted as a stipple number to fill the polygon with β the number indexes into a stipple font at print time. Iconic behaviour honestly. - π The last line of every element has a decimal number and a string of characters, separated by a single space. The number is a count of how many characters are in the string. This info is used only for text elements, and it holds the text string itself. There can be spaces inside the text, bestie β it's fine. For arcs, curves, and vectors, the character count is zero (
0), followed by exactly one space before the newline. Exactly one. Don't get creative with it π.
πΊοΈ Coordinates
gremlin was designed for AED terminals, and its coordinates reflect the AED coordinate space, periodt.
- For vertical pictures,
xvalues range116to511, andyvalues from0to483. - For horizontal pictures,
xvalues range from0to511, andyvalues from0to367.
You don't absolutely have to stick to that range, but ngl you'll get better results if you at least stay in the vicinity. Also β point lists are terminated by a point of (-1, -1), so you should never ever use negative coordinates. gremlin writes out coordinates using the printf(3) format %f1.2; it's probably a good idea to use that same format if you want to modify the grn code. Consistency slays π
βοΈ Sun/X11 coordinates
There is no restriction on the range of coordinates used to create objects in the Sun/X11 version of gremlin. Freedom! π
But fr fr β files with negative coordinates will cause problems if displayed on the AED. So like, know your audience π
β¨ OPTIONS β¨
-?and--helpβ display a usage message. Both exit afterward.-vand--versionβ show version information. Also exits afterward. (Yes, all of these bounce right after doing their one job π)-Cβ recognize.GSand.GE(and.GF) even when they're followed by a character other than a space or newline.-Fdir β search dir for subdirectoriesdevname(name is the name of the output driver) for theDESCfile before the default font directories/usr/share/groff/site-font,/usr/share/groff/1.24.2/font, and/usr/lib/font.-Mdir β prepend dir to the search path forgremlinfiles. The default search path is the current directory, the home directory,/usr/share/groff/site-tmac, and/usr/share/groff/1.24.2/tmac, in that order. Order matters, bestie π«Ά-Tdev β prepare device output using output driver dev. The default isps. Seegroff(1)for a list of valid devices.
πͺ EXIT STATUS
grn exits with:
- status
0on successful operation π - status
2if the program cannot interpret its command-line arguments π - status
1if it encounters an error during operation π
π FILES
/usr/share/groff/1.24.2/font/devname/DESCβ describes the output device name.
π AUTHORS
David Slattengren and Barry Roitblat wrote the original Berkeley grn. Daniel Senderowicz and Werner Lemberg modified it for groff. Legends, all of them π
π¦ SEE ALSO
gremlin(1), groff(1), pic(1), ideal(1) β go read the whole friend group β¨
And that's the whole page, bestie! This masterpiece is groff 1.24.2, dated 2026-10-01, and it's grn(1) β go make some iconic little diagrams with it ππ
π¦ where this page comes from
- alpine 3.24: groff-doc 1.24.2-r0 Β· GPL-3.0-or-later
- Copyright (C) 2000-2024 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms