1grops(1) General Commands Manual grops(1)
2
3
4
6 grops - groff output driver for PostScript
7
9 grops [-glm] [-b brokenness-flags] [-c num-copies] [-F font-directory]
10 [-I inclusion-directory] [-p paper-format] [-P prologue-file]
11 [-w rule-thickness] [file ...]
12
13 grops --help
14
15 grops -v
16 grops --version
17
19 The GNU roff PostScript output driver translates the output of troff(1)
20 into PostScript. Normally, grops is invoked by groff(1) when the lat‐
21 ter is given the “-T ps” option. (In this installation, ps is the de‐
22 fault output device.) Use groff's -P option to pass any options shown
23 above to grops. If no file arguments are given, or if file is “-”,
24 grotty reads the standard input stream. Output is written to the stan‐
25 dard output stream.
26
27 When called with multiple file arguments, grops doesn't produce a valid
28 document structure (one conforming to the Document Structuring Conven‐
29 tions). To print such concatenated output, it is necessary to deacti‐
30 vate DSC handling in the printing program or previewer.
31
32 See section “Font installation” below for a guide to installing fonts
33 for grops.
34
36 --help displays a usage message, while -v and --version show version
37 information; all exit afterward.
38
39 -b n Work around problems with spoolers, previewers, and older print‐
40 ers. Normally, grops produces output at PostScript
41 LanguageLevel 2 that conforms to version 3.0 of the Document
42 Structuring Conventions. Some software and devices can't handle
43 such a data stream. The value of n determines what grops does
44 to make its output acceptable to such consumers. If n is 0,
45 grops employs no workarounds, which is the default; it can be
46 changed by modifying the broken directive in grops's DESC file.
47
48 Add 1 to suppress generation of %%BeginDocumentSetup and %%End‐
49 DocumentSetup comments; this is needed for early versions of
50 TranScript that get confused by anything between the %%EndProlog
51 comment and the first %%Page comment.
52
53 Add 2 to omit lines in included files beginning with %!, which
54 confuse Sun's pageview previewer.
55
56 Add 4 to omit lines in included files beginning with %%Page,
57 %%Trailer and %%EndProlog; this is needed for spoolers that
58 don't understand %%BeginDocument and %%EndDocument comments.
59
60 Add 8 to write %!PS-Adobe-2.0 rather than %!PS-Adobe-3.0 as the
61 first line of the PostScript output; this is needed when using
62 Sun's Newsprint with a printer that requires page reversal.
63
64 Add 16 to omit media size information (that is, output neither a
65 %%DocumentMedia comment nor the setpagedevice PostScript com‐
66 mand). This was the behavior of groff 1.18.1 and earlier; it is
67 needed for older printers that don't understand PostScript
68 LanguageLevel 2, and is also necessary if the output is further
69 processed to produce an EPS file; see subsection “Escapsulated
70 PostScript” below.
71
72 -c n Output n copies of each page.
73
74 -F dir Prepend directory dir/devname to the search path for font and
75 device description and PostScript prologue files; name is the
76 name of the device, usually ps.
77
78 -g Generate PostScript code to guess the page length. The guess is
79 correct only if the imageable area is vertically centered on the
80 page. This option allows you to generate documents that can be
81 printed on both U.S. letter and A4 paper formats without change.
82
83 -I dir Search the directory dir for files named in \X'ps: file' and
84 \X'ps: import' escape sequences. -I may be specified more than
85 once; each dir is searched in the given order. To search the
86 current working directory before others, add “-I .” at the de‐
87 sired place; it is otherwise searched last.
88
89 -l Use landscape orientation rather than portrait.
90
91 -m Turn on manual feed for the document.
92
93 -p fmt Set physical dimensions of output medium, overriding the
94 papersize, paperlength, and paperwidth directives in the DESC
95 file. fmt can be any argument accepted by the papersize direc‐
96 tive; see groff_font(5).
97
98 -P prologue
99 Use the file prologue, sought in the groff font search path, as
100 the PostScript prologue, overriding the default (see section
101 “Files” below) and the environment variable GROPS_PROLOGUE.
102
103 -w n Draw rules (lines) with a thickness of n thousandths of an em.
104 The default thickness is 40 (0.04 em).
105
107 The input to grops must be in the format output by troff(1), described
108 in groff_out(5). In addition, the device and font description files
109 for the device used must meet certain requirements. The device resolu‐
110 tion must be an integer multiple of 72 times the sizescale. The device
111 description file must contain a valid paper format; see groff_font(5).
112 Each font description file must contain a directive
113 internalname psname
114 which says that the PostScript name of the font is psname.
115
116 A font description file may also contain a directive
117 encoding enc-file
118 which says that the PostScript font should be reencoded using the en‐
119 coding described in enc-file; this file should consist of a sequence of
120 lines of the form
121 pschar code
122 where pschar is the PostScript name of the character, and code is its
123 position in the encoding expressed as a decimal integer; valid values
124 are in the range 0 to 255. Lines starting with # and blank lines are
125 ignored. The code for each character given in the font description
126 file must correspond to the code for the character in encoding file, or
127 to the code in the default encoding for the font if the PostScript font
128 is not to be reencoded. This code can be used with the \N escape se‐
129 quence in troff to select the character, even if it does not have a
130 groff glyph name. Every character in the font description file must
131 exist in the PostScript font, and the widths given in the font descrip‐
132 tion file must match the widths used in the PostScript font. grops as‐
133 sumes that a character with a groff name of space is blank (makes no
134 marks on the page); it can make use of such a character to generate
135 more efficient and compact PostScript output.
136
137 grops is able to display all glyphs in a PostScript font; it is not
138 limited to 256 of them. enc-file (or the default encoding if no encod‐
139 ing file is specified) just defines the order of glyphs for the first
140 256 characters; all other glyphs are accessed with additional encoding
141 vectors which grops produces on the fly.
142
143 grops can embed fonts in a document that are necessary to render it;
144 this is called “downloading”. Such fonts must be in PFA format. Use
145 pfbtops(1) to convert a Type 1 font in PFB format. Downloadable fonts
146 must be listed a download file containing lines of the form
147 psname file
148 where psname is the PostScript name of the font, and file is the name
149 of the file containing it; lines beginning with # and blank lines are
150 ignored; fields may be separated by tabs or spaces. file is sought us‐
151 ing the same mechanism as that for groff font description files. The
152 download file itself is also sought using this mechanism; currently,
153 only the first matching file found in the device and font description
154 search path is used.
155
156 If the file containing a downloadable font or imported document con‐
157 forms to the Adobe Document Structuring Conventions, then grops inter‐
158 prets any comments in the files sufficiently to ensure that its own
159 output is conforming. It also supplies any needed font resources that
160 are listed in the download file as well as any needed file resources.
161 It is also able to handle inter-resource dependencies. For example,
162 suppose that you have a downloadable font called Garamond, and also a
163 downloadable font called Garamond-Outline which depends on Garamond
164 (typically it would be defined to copy Garamond's font dictionary, and
165 change the PaintType), then it is necessary for Garamond to appear be‐
166 fore Garamond-Outline in the PostScript document. grops handles this
167 automatically provided that the downloadable font file for Garamond-
168 Outline indicates its dependence on Garamond by means of the Document
169 Structuring Conventions, for example by beginning with the following
170 lines.
171 %!PS-Adobe-3.0 Resource-Font
172 %%DocumentNeededResources: font Garamond
173 %%EndComments
174 %%IncludeResource: font Garamond
175 In this case, both Garamond and Garamond-Outline would need to be
176 listed in the download file. A downloadable font should not include
177 its own name in a %%DocumentSuppliedResources comment.
178
179 grops does not interpret %%DocumentFonts comments. The %%Document‐
180 NeededResources, %%DocumentSuppliedResources, %%IncludeResource,
181 %%BeginResource, and %%EndResource comments (or possibly the old
182 %%DocumentNeededFonts, %%DocumentSuppliedFonts, %%IncludeFont, %%Begin‐
183 Font, and %%EndFont comments) should be used.
184
185 The default stroke and fill color is black. For colors defined in the
186 “rgb” color space, setrgbcolor is used; for “cmy” and “cmyk”, setcmyk‐
187 color; and for “gray”, setgray. setcmykcolor is a PostScript
188 LanguageLevel 2 command and thus not available on some older printers.
189
190 Typefaces
191 Styles called R, I, B, and BI mounted at font positions 1 to 4. Text
192 fonts are grouped into families A, BM, C, H, HN, N, P, and T, each hav‐
193 ing members in each of these styles.
194
195 AR AvantGarde-Book
196 AI AvantGarde-BookOblique
197 AB AvantGarde-Demi
198 ABI AvantGarde-DemiOblique
199 BMR Bookman-Light
200 BMI Bookman-LightItalic
201 BMB Bookman-Demi
202 BMBI Bookman-DemiItalic
203 CR Courier
204 CI Courier-Oblique
205 CB Courier-Bold
206 CBI Courier-BoldOblique
207 HR Helvetica
208 HI Helvetica-Oblique
209 HB Helvetica-Bold
210 HBI Helvetica-BoldOblique
211 HNR Helvetica-Narrow
212 HNI Helvetica-Narrow-Oblique
213 HNB Helvetica-Narrow-Bold
214 HNBI Helvetica-Narrow-BoldOblique
215 NR NewCenturySchlbk-Roman
216 NI NewCenturySchlbk-Italic
217 NB NewCenturySchlbk-Bold
218 NBI NewCenturySchlbk-BoldItalic
219 PR Palatino-Roman
220 PI Palatino-Italic
221 PB Palatino-Bold
222 PBI Palatino-BoldItalic
223 TR Times-Roman
224 TI Times-Italic
225 TB Times-Bold
226 TBI Times-BoldItalic
227
228 Another text font is not a member of a family.
229
230 ZCMI ZapfChancery-MediumItalic
231
232 Special fonts include S, the PostScript Symbol font; ZD, Zapf Dingbats;
233 SS (slanted symbol), which contains oblique forms of lowercase Greek
234 letters derived from Symbol; EURO, which offers a Euro glyph for use
235 with old devices lacking it; and ZDR, a reversed version of ZapfDing‐
236 bats (with symbols flipped about the vertical axis). Most glyphs in
237 these fonts are unnamed and must be accessed using \N. The last three
238 are not standard PostScript fonts, but supplied by groff and therefore
239 included in the default download file.
240
241 Device control commands
242 grops recognizes device control commands produced by the \X escape se‐
243 quence, but interprets only those that begin with a “ps:” tag.
244
245 \X'ps: exec code'
246 Execute the arbitrary PostScript commands code. The PostScript
247 currentpoint is set to the groff drawing position when the \X
248 escape sequence is interpreted before executing code. The ori‐
249 gin is at the top left corner of the page; x coordinates in‐
250 crease to the right, and y coordinates down the page. A proce‐
251 dure u is defined that converts groff basic units to the coordi‐
252 nate system in effect (provided the user doesn't change the
253 scale). For example,
254 .nr x 1i
255 \X'ps: exec \nx u 0 rlineto stroke'
256 draws a horizontal line one inch long. code may make changes to
257 the graphics state, but any changes persist only to the end of
258 the page. A dictionary containing the definitions specified by
259 the def and mdef commands is on top of the dictionary stack. If
260 your code adds definitions to this dictionary, you should allo‐
261 cate space for them using “\X'ps: mdef n'”. Any definitions
262 persist only until the end of the page. If you use the \Y es‐
263 cape sequence with an argument that names a macro, code can ex‐
264 tend over multiple lines. For example,
265 .nr x 1i
266 .de y
267 ps: exec
268 \nx u 0 rlineto
269 stroke
270 ..
271 \Yy
272 is another way to draw a horizontal line one inch long. The
273 single backslash before “nx”—the only reason to use a register
274 while defining the macro “y”—is to convert a user-specified di‐
275 mension “1i” to groff basic units which are in turn converted to
276 PostScript units with the u procedure.
277
278 grops wraps user-specified PostScript code into a dictionary,
279 nothing more. In particular, it doesn't start and end the in‐
280 serted code with save and restore, respectively. This must be
281 supplied by the user, if necessary.
282
283 \X'ps: file name'
284 This is the same as the exec command except that the PostScript
285 code is read from file name.
286
287 \X'ps: def code'
288 Place a PostScript definition contained in code in the prologue.
289 There should be at most one definition per \X command. Long
290 definitions can be split over several \X commands; all the code
291 arguments are simply joined together separated by newlines. The
292 definitions are placed in a dictionary which is automatically
293 pushed on the dictionary stack when an exec command is executed.
294 If you use the \Y escape sequence with an argument that names a
295 macro, code can extend over multiple lines.
296
297 \X'ps: mdef n code'
298 Like def, except that code may contain up to n definitions.
299 grops needs to know how many definitions code contains so that
300 it can create an appropriately sized PostScript dictionary to
301 contain them.
302
303 \X'ps: import file llx lly urx ury width [height]'
304 Import a PostScript graphic from file. The arguments llx, lly,
305 urx, and ury give the bounding box of the graphic in the default
306 PostScript coordinate system. They should all be integers: llx
307 and lly are the x and y coordinates of the lower left corner of
308 the graphic; urx and ury are the x and y coordinates of the up‐
309 per right corner of the graphic; width and height are integers
310 that give the desired width and height in groff basic units of
311 the graphic.
312
313 The graphic is scaled so that it has this width and height and
314 translated so that the lower left corner of the graphic is lo‐
315 cated at the position associated with \X command. If the height
316 argument is omitted it is scaled uniformly in the x and y axes
317 so that it has the specified width.
318
319 The contents of the \X command are not interpreted by troff, so
320 vertical space for the graphic is not automatically added, and
321 the width and height arguments are not allowed to have attached
322 scaling indicators.
323
324 If the PostScript file complies with the Adobe Document Struc‐
325 turing Conventions and contains a %%BoundingBox comment, then
326 the bounding box can be automatically extracted from within
327 groff input by using the psbb request.
328
329 See groff_tmac(5) for a description of the PSPIC macro which
330 provides a convenient high-level interface for inclusion of
331 PostScript graphics.
332
333 \X'ps: invis'
334 \X'ps: endinvis'
335 No output is generated for text and drawing commands that are
336 bracketed with these \X commands. These commands are intended
337 for use when output from troff is previewed before being pro‐
338 cessed with grops; if the previewer is unable to display certain
339 characters or other constructs, then other substitute characters
340 or constructs can be used for previewing by bracketing them with
341 these \X commands.
342
343 For example, gxditview is not able to display a proper \[em]
344 character because the standard X11 fonts do not provide it; this
345 problem can be overcome by executing the following request
346
347 .char \[em] \X'ps: invis'\
348 \Z'\v'-.25m'\h'.05m'\D'l .9m 0'\h'.05m''\
349 \X'ps: endinvis'\[em]
350
351 In this case, gxditview is unable to display the \[em] character
352 and draws the line, whereas grops prints the \[em] character and
353 ignores the line (this code is already in file Xps.tmac, which
354 is loaded if a document intended for grops is previewed with
355 gxditview).
356
357 If a PostScript procedure BPhook has been defined via a “ps: def” or
358 “ps: mdef” device control command, it is executed at the beginning of
359 every page (before anything is drawn or written by groff). For exam‐
360 ple, to underlay the page contents with the word “DRAFT” in light gray,
361 you might use
362
363 .de XX
364 ps: def
365 /BPhook
366 { gsave .9 setgray clippath pathbbox exch 2 copy
367 .5 mul exch .5 mul translate atan rotate pop pop
368 /NewCenturySchlbk-Roman findfont 200 scalefont setfont
369 (DRAFT) dup stringwidth pop -.5 mul -70 moveto show
370 grestore }
371 def
372 ..
373 .devicem XX
374
375 Or, to cause lines and polygons to be drawn with square linecaps and
376 mitered linejoins instead of the round linecaps and linejoins normally
377 used by grops, use
378 .de XX
379 ps: def
380 /BPhook { 2 setlinecap 0 setlinejoin } def
381 ..
382 .devicem XX
383 (square linecaps, as opposed to butt linecaps (“0 setlinecap”), give
384 true corners in boxed tables even though the lines are drawn uncon‐
385 nected).
386
387 Encapsulated PostScript
388 grops itself doesn't emit bounding box information. The following
389 script, groff2eps, produces an EPS file.
390
391 #! /bin/sh
392 groff -P-b16 "$1" > "$1".ps
393 gs -dNOPAUSE -sDEVICE=bbox -- "$1".ps 2> "$1".bbox
394 sed -e "/^%%Orientation/r $1.bbox" \
395 -e "/^%!PS-Adobe-3.0/s/$/ EPSF-3.0/" "$1".ps > "$1".eps
396 rm "$1".ps "$1".bbox
397
398 You can then use “groff2eps foo” to convert file foo to foo.eps.
399
400 TrueType and other font formats
401 TrueType fonts can be used with grops if converted first to Type 42
402 format, a PostScript wrapper equivalent to the PFA format described in
403 pfbtops(1). Several methods exist to generate a Type 42 wrapper; some
404 of them involve the use of a PostScript interpreter such as Ghost‐
405 script—see gs(1).
406
407 One approach is to use FontForge ⟨https://fontforge.org/⟩, a font edi‐
408 tor that can convert most outline font formats. Here's an example of
409 using the Roboto Slab Serif font with groff. Several variables are
410 used so that you can more easily adapt it into your own script.
411
412 MAP=/usr/share/groff/1.23.0/font/devps/generate/text.map
413 TTF=/usr/share/fonts/truetype/roboto/slab/RobotoSlab-Regular.ttf
414 BASE=$(basename "$TTF")
415 INT=${BASE%.ttf}
416 PFA=$INT.pfa
417 AFM=$INT.afm
418 GFN=RSR
419 DIR=$HOME/.local/groff/font
420 mkdir -p "$DIR"/devps
421 fontforge -lang=ff -c "Open(\"$TTF\");\
422 Generate(\"$DIR/devps/$PFA\");"
423 afmtodit "$DIR/devps/$AFM" "$MAP" "$DIR/devps/$GFN"
424 printf "$BASE\t$PFA\n" >> "$DIR/devps/download"
425
426 fontforge and afmtodit may generate warnings depending on the at‐
427 tributes of the font. The test procedure is simple.
428
429 printf ".ft RSR\nHello, world!\n" | groff -F "$DIR" > hello.ps
430
431 Once you're satisfied that the font works, you may want to generate any
432 available related styles (for instance, Roboto Slab also has “Bold”,
433 “Light”, and “Thin” styles) and set up GROFF_FONT_PATH in your environ‐
434 ment to include the directory you keep the generated fonts in so that
435 you don't have to use the -F option.
436
438 The following is a step-by-step font installation guide for grops.
439
440 • Convert your font to something groff understands. This is a Post‐
441 Script Type 1 font in PFA format or a PostScript Type 42 font, to‐
442 gether with an AFM file. A PFA file begins as follows.
443 %!PS-AdobeFont-1.0:
444 A PFB file contains this string as well, preceded by some non-print‐
445 ing bytes. If your font is in PFB format, use groff's pfbtops(1)
446 program to convert it to PFA. For TrueType and other font formats,
447 we recommend fontforge, which can convert most outline font formats.
448 A Type 42 font file begins as follows.
449 %!PS-TrueTypeFont
450 This is a wrapper format for TrueType fonts. Old PostScript printers
451 might not support them (that is, they might not have a built-in True‐
452 Type font interpreter). In the following steps, we will consider the
453 use of CTAN's BrushScriptX-Italic ⟨https://ctan.org/tex-archive/
454 fonts/brushscr⟩ font in PFA format.
455
456 • Convert the AFM file to a groff font description file with the
457 afmtodit(1) program. For instance,
458 $ afmtodit BrushScriptX-Italic.afm text.map BSI
459 converts the Adobe Font Metric file BrushScriptX-Italic.afm to the
460 groff font description file BSI.
461
462 If you have a font family which provides regular upright (roman),
463 bold, italic, and bold-italic styles (where “italic” may be “oblique”
464 or “slanted”), we recommend using the letters R, B, I, and BI, re‐
465 spectively, as suffixes to the groff font family name to enable
466 groff's font family and style selection features. An example is
467 groff's built-in support for Times: the font family name is abbrevi‐
468 ated as T, and the groff font names are therefore TR, TB, TI, and
469 TBI. In our example, however, the BrushScriptX font is available in
470 a single style only, italic.
471
472 • Install the groff font description file(s) in a devps subdirectory in
473 the search path that groff uses for device and font file descrip‐
474 tions. See the GROFF_FONT_PATH entry in section “Environment” of
475 troff(1) for the current value of the font search path. While groff
476 doesn't directly use AFM files, it is a good idea to store them
477 alongside its font description files.
478
479 • Register fonts in the devps/download file so they can be located for
480 embedding in PostScript files grops generates. Only the first down‐
481 load file encountered in the font search path is read. If in doubt,
482 copy the default download file (see section “Files” below) to the
483 first directory in the font search path and add your fonts there.
484 The PostScript font name used by grops is stored in the internalname
485 field in the groff font description file. (This name does not neces‐
486 sarily resemble the font's file name.) We add the following line to
487 download.
488 BrushScriptX-Italic→BrushScriptX-Italic.pfa
489 A tab character, depicted as →, separates the fields.
490
491 • Test the selection and embedding of the new font.
492 printf "\\f[BSI]Hello, world!\n" | groff -T ps -P -e >hello.ps
493 see hello.pdf
494
496 groff versions 1.19.2 and earlier contained descriptions of a slightly
497 different set of the base 35 PostScript level 2 fonts defined by Adobe.
498 The older set has 229 glyphs and a larger set of kerning pairs; the
499 newer one has 314 glyphs and includes the Euro glyph. For backwards
500 compatibility, these old font descriptions are also installed in the
501 /usr/share/groff/1.23.0/oldfont/devps directory.
502
503 To use them, make sure that grops finds the fonts before the default
504 system fonts (with the same names): either give grops the -F command-
505 line option,
506 $ groff -Tps -P-F -P/usr/share/groff/1.23.0/oldfont ...
507 or add the directory to groff's font and device description search path
508 environment variable,
509 $ GROFF_FONT_PATH=/usr/share/groff/1.23.0/oldfont \
510 groff -Tps ...
511 when the command runs.
512
514 GROFF_FONT_PATH
515 A list of directories in which to seek the selected output de‐
516 vice's directory of device and font description files. See
517 troff(1) and groff_font(5).
518
519 GROPS_PROLOGUE
520 If this is set to foo, then grops uses the file foo (in the font
521 path) instead of the default prologue file prologue. The option
522 -P overrides this environment variable.
523
524 SOURCE_DATE_EPOCH
525 A timestamp (expressed as seconds since the Unix epoch) to use
526 as the output creation timestamp in place of the current time.
527 The time is converted to human-readable form using ctime(3) and
528 recorded in a PostScript comment.
529
530 TZ The time zone to use when converting the current time (or value
531 of SOURCE_DATE_EPOCH) to human-readable form; see tzset(3).
532
534 /usr/share/groff/1.23.0/font/devps/DESC
535 describes the ps output device.
536
537 /usr/share/groff/1.23.0/font/devps/F
538 describes the font known as F on device ps.
539
540 /usr/share/groff/1.23.0/font/devps/download
541 lists fonts available for embedding within the PostScript docu‐
542 ment (or download to the device).
543
544 /usr/share/groff/1.23.0/font/devps/prologue
545 is the default PostScript prologue prefixed to every output
546 file.
547
548 /usr/share/groff/1.23.0/font/devps/text.enc
549 describes the encoding scheme used by most PostScript Type 1
550 fonts; the encoding directive of font description files for the
551 ps device refers to it.
552
553 /usr/share/groff/1.23.0/tmac/ps.tmac
554 defines macros for use with the ps output device. It is auto‐
555 matically loaded by troffrc when the ps output device is se‐
556 lected.
557
558 /usr/share/groff/1.23.0/tmac/pspic.tmac
559 defines the PSPIC macro for embedding images in a document; see
560 groff_tmac(5). It is automatically loaded by troffrc.
561
562 /usr/share/groff/1.23.0/tmac/psold.tmac
563 provides replacement glyphs for text fonts that lack complete
564 coverage of the ISO Latin-1 character set; using it, groff can
565 produce glyphs like eth (ð) and thorn (þ) that older PostScript
566 printers do not natively support.
567
568 grops creates temporary files using the template “gropsXXXXXX”; see
569 groff(1) for details on their storage location.
570
572 PostScript Language Document Structuring Conventions Specification
573 ⟨http://partners.adobe.com/public/developer/en/ps/5001.DSC_Spec.pdf⟩
574
575 afmtodit(1), groff(1), troff(1), pfbtops(1), groff_char(7),
576 groff_font(5), groff_out(5), groff_tmac(5)
577
578
579
580groff 1.23.0 2 November 2023 grops(1)