groff_out.5
Last update: 12 Sep 2002
This file is part of groff, the GNU roff type-setting system.
Copyright (C) 1989, 2001, 2002 Free Software Foundation, Inc.
rewritten from scrach 2001 by Bernd Warken <bwarken@mayn.de>
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with the
Invariant Sections being this .ig-section and AUTHORS, with no
Front-Cover Texts, and with no Back-Cover Texts.
A copy of the Free Documentation License is included as a file called
FDL in the main directory of the groff source package.
A copy of the GNU Free Documentation License is also available in this
Debian package as /usr/share/doc/groff/copyright.
.
.
.
.
.
delim $$
.
.
.
Unfortunately, old versions of groff used an illogical position change
after some D\~commands (Dp, DP, Dt). If the number register
@STUPID_DRAWING_POSITIONING is 1 (actual default) then change position
after these commands, otherwise the position is not changed.
.
.
.
.
.
.
.
.
.
.
.
NAME
groff_out - groff intermediate output format
.
.
DESCRIPTION
.
This manual page describes the intermediate output format of the GNU
roff(7)
text processing system.
.
This output is produced by a run of the GNU
troff(1)
program before it is fed into a device postprocessor program.
.
As the GNU roff processor
groff(1)
is a wrapper program around troff that automatically calls a
postprocessor, this output does not show up normally.
.
This is why it is called
intermediate
within the
groff
R system .
.
The
groff
program provides the option
-Z
to inhibit postprocessing, such that the produced intermediate output
is sent to standard output just like calling
troff
manually.
.
In this document, the term
troff output
describes what is output by the GNU troff program, while
intermediate output
refers to the language that is accepted by the parser that prepares
this output for the postprocessors.
.
This parser is smarter on whitespace and implements obsolete elements
for compatibility, otherwise both formats are the same.
.
The pre-groff roff versions are denoted as
classical
R troff .
.
The main purpose of the intermediate output concept is to facilitate
the development of postprocessors by providing a common programming
interface for all devices.
.
It has a language of its own that is completely different from the
groff(7)
language.
.
While the
groff
language is a high-level programming language for text processing, the
intermediate output language is a kind of low-level assembler language
by specifying all positions on the page for writing and drawing.
.
The intermediate output produced by
groff
is fairly readable, while
classical troff
output was hard to understand because of strange habits that are
still supported, but not used any longer by
GNU
R troff .
.
.
LANGUAGE CONCEPTS
.
During the run of
R troff ,
the roff input is cracked down to the information on what has to be
printed at what position on the intended device.
.
So the language of the intermediate output format can be quite small.
.
Its only elements are commands with or without arguments.
.
In this document, the term "command" always refers to the intermediate
output language, never to the roff language used for document
formatting.
.
There are commands for positioning and text writing, for drawing, and
for device controlling.
.
.
Separation
.
Classical troff output
had strange requirements on whitespace.
.
The
groff
output parser, however, is smart about whitespace by making it
maximally optional.
.
The whitespace characters, i.e. the
R tab ,
R space ,
and
newline
characters, always have a syntactical meaning.
.
They are never printable because spacing within the output is always
done by positioning commands.
.
Any sequence of
space
or
tab
characters is treated as a single
syntactical
R space .
.
It separates commands and arguments, but is only required when there
would occur a clashing between the command code and the arguments
without the space.
.
Most often, this happens when variable length command names,
arguments, argument lists, or command clusters meet.
.
Commands and arguments with a known, fixed length need not be
separated by syntactical space.
.
A line break is a syntactical element, too.
.
Every command argument can be followed by whitespace, a comment, or a
newline character.
.
Thus a
syntactical line break
is defined to consist of optional syntactical space that is optionally
followed by a comment, and a newline character.
.
The normal commands, those for positioning and text, consist of a
single letter taking a fixed number of arguments.
.
For historical reasons, the parser allows to stack such commands on
the same line, but fortunately, in groff intermediate output, every
command with at least one argument is followed by a line break, thus
providing excellent readability.
.
The other commands \[em] those for drawing and device controlling \[em]
have a more complicated structure; some recognize long command names,
and some take a variable number of arguments.
.
So all
D
and
x
commands were designed to request a
syntactical line break
after their last argument.
.
Only one command,
`x\X'
has an argument that can stretch over several lines, all other
commands must have all of their arguments on the same line as the
command, i.e. the arguments may not be splitted by a line break.
.
Empty lines, i.e. lines containing only space and/or a comment, can
occur everywhere.
.
They are just ignored.
.
.
Argument Units
.
Some commands take integer arguments that are assumed to represent
values in a measurement unit, but the letter for the corresponding
scale indicator
is not written with the output command arguments; see
groff(7)
and the groff info file for more on this topic.
.
Most commands assume the scale indicator\~\c
the basic unit of the device, some use\~\c
the
scaled point unit
of the device, while others, such as the color commands expect plain
integers.
.
Note that these scale indicators are relative to the chosen device.
.
They are defined by the parameters specified in the device's
DESC
file; see
groff_font(5).
.
Note that single characters can have the eighth bit set, as can the
names of fonts and special characters.
.
The names of characters and fonts can be of arbitrary length.
.
A character that is to be printed will always be in the current font.
.
A string argument is always terminated by the next whitespace
character (space, tab, or newline); an embedded
#
character is regarded as part of the argument, not as the beginning of
a comment command.
.
An integer argument is already terminated by the next non-digit
character, which then is regarded as the first character of the next
argument or command.
.
.
Document Parts
A correct intermediate output document consists of two parts, the
prologue and the body.
.
The task of the
prologue
is to set the general device parameters using three exactly specified
commands.
.
The
groff prologue
is guaranteed to consist of the following three lines (in that order):
x T
device
x res
n h v
x init
with the arguments set as outlined in the section
R Device Control Commands .
.
But the parser for the intermediate output format is able to swallow
additional whitespace and comments as well.
.
The
body
is the main section for processing the document data.
.
Syntactically, it is a sequence of any commands different from the
ones used in the prologue.
.
Processing is terminated as soon as the first
x stop
command is encountered; the last line of any groff intermediate output
always contains such a command.
.
Semantically, the body is page oriented.
.
A new page is started by a
R p \~command.
.
Positioning, writing, and drawing commands are always done within the
current page, so they cannot occur before the first
R p \~command.
.
Absolute positioning (by the
H
and
R V \~commands)
is done relative to the current page, all other positioning
is done relative to the current location within this page.
.
.
COMMAND REFERENCE
.
This section describes all intermediate output commands, the classical
commands as well as the
groff
extensions.
.
.
Comment Command
.
I # anything \[la]end_of_line\[ra]
A comment.
.
Ignore any characters from the
R # \~\c
character up to the next newline character.
.
This command is the only possibility for commenting in the intermediate
output.
.
Each comment can be preceded by arbitrary
syntactical
R space ;
every command can be terminated by a comment.
.
.
Simple Commands
.
The commands in this subsection have a command code consisting of a
single character, taking a fixed number of arguments.
.
Most of them are commands for positioning and text writing.
.
These commands are smart about whitespace.
.
Optionally,
syntactical space
can be inserted before, after, and between the command letter and its
arguments.
.
All of these commands are stackable, i.e., they can be preceded by
other simple commands or followed by arbitrary other commands on the
same line.
.
A separating syntactical space is only necessary when two integer
arguments would clash or if the preceding argument ends with a string
argument.
.
.
Open a new environment by copying the actual device configuration data
to the environment stack.
.
The current environment is setup by the device specification and
manipulated by the setting commands.
.
.
Close the actual environment (opened by a preceding
R { \~command)
and restore the previous environment from the environment
stack as the actual device configuration data.
.
\} \" endif @USE_ENV_STACK
.
.
Print a special groff character named
.
The trailing syntactical space or line break is necessary to allow
character names of arbitrary length.
.
The character is printed at the current print position;
the character's size is read from the font file.
.
The print position is not changed.
.
.
Print character\~\c
at the current print position;
the character's size is read from the font file.
.
The print position is not changed.
.
.
Set font to font number\~\c
(a non-negative integer).
.
.
Move right to the absolute vertical position\~\c
(a non-negative integer in basic units\~\c
relative to left edge of current page.
.
.
Move
(a non-negative integer) basic units\~\c
horizontally to the right.
.
[54]
allows negative values for
n
also, but
groff
doesn't use this.
.
.
Set the color for text (glyphs), line drawing, and the outline of
graphic objects using different color schemes; the analoguous command
for the filling color of graphic objects is
R DF .
.
The color components are specified as integer arguments between 0 and
\n[@maxcolor].
.
The number of color components and their meaning vary for the
different color schemes.
.
These commands are generated by the groff escape sequence
R \*[@backslash]m .
.
No position changing.
.
These commands are a groff extension.
.
.
.
Set color using the CMY color scheme, having the 3\~color components
cyan, magenta, and yellow.
.
.
Set color to the default color value
(black in most cases).
.
No component arguments.
.
.
Set color to the shade of gray given by the argument, an integer
between 0 (black) and \n[@maxcolor] (white).
.
.
Set color using the CMYK color scheme, having the 4\~color components
cyan, magenta, yellow, and black.
.
Set color using the RGB color scheme, having the 3\~color components
red, green, and blue.
.
.
.
Print character with index\~\c
(a non-negative integer) of the current font.
.
The print position is not changed.
.
This command is a groff extension.
.
.
Inform the device about a line break, but no positioning is done by
this command.
.
In classical troff, the integer arguments
and\~\c
informed about the space before and after the current line to
make the intermediate output more human readable without performing
any action.
.
In groff, they are just ignored, but they must be provided for
compatibility reasons.
.
.
Begin a new page in the outprint.
.
The page number is set to\~\c
.
This page is completely independent of pages formerly processed even
if those have the same page number.
.
The vertical position on the outprint is automatically set to\~0.
.
All positioning, writing, and drawing is always done relative to a
page, so a
R p \~command
must be issued before any of these commands.
.
.
Set point size to
scaled points
(this is unit\~\c
in GNU
R troff ).
.
Classical troff used the unit
points
(\c
instead; see section
R COMPATIBILITY .
.
.
Print a word, i.e. a sequence of characters
terminated by a space character or a line break; an optional second
integer argument is ignored (this allows the formatter to generate
an even number of arguments).
.
The first character should be printed at the current position, the
current horizontal position should then be increased by the width of
the first character, and so on for each character.
.
The widths of the characters are read from the font file, scaled for the
current point size, and rounded to a multiple of the horizontal
resolution.
.
Special characters cannot be printed using this command (use the
C
command for named characters).
.
This command is a groff extension; it is only used for devices whose
DESC
file contains the
tcommand
keyword; see
groff_font(5).
.
.
Print word with track kerning.
.
This is the same as the
t
command except that after printing each character, the current
horizontal position is increased by the sum of the width of that
character and\~\c
(an integer in
basic units\~\c
This command is a groff extension; it is only used for devices whose
DESC
file contains the
tcommand
keyword; see
groff_font(5).
.
.
Move down to the absolute vertical position\~\c
(a non-negative integer in basic units\~\c
relative to upper edge of current page.
.
.
Move
basic units\~\c
down
(n
is a non-negative integer).
.
[54]
allows negative values for
n
also, but
groff
doesn't use this.
.
.
Informs about a paddable whitespace to increase readability.
.
The spacing itself must be performed explicitly by a move command.
.
.
Graphics Commands
.
Each graphics or drawing command in the intermediate output starts
with the letter\~\c
D
followed by one or two characters that specify a subcommand; this
is followed by a fixed or variable number of integer arguments that
are separated by a single space character.
.
A
R D command
may not be followed by another command on the same line
(apart from a comment), so each
R D command
is terminated by a syntactical line break.
.
troff
output follows the classical spacing rules (no space between command
and subcommand, all arguments are preceded by a single space
character), but the parser allows optional space between the command
letters and makes the space before the first argument optional.
.
As usual, each space can be any sequence of tab and space characters.
.
Some graphics commands can take a variable number of arguments.
.
In this case, they are integers representing a size measured in basic
units\~\c
.
The arguments called
stand for horizontal distances where positive means right, negative
left.
.
The arguments called
stand for vertical distances where positive means down, negative up.
.
All these distances are offsets relative to the current location.
.
Unless indicated otherwise, each graphics command directly corresponds
to a similar
groff
\*[@backslash]D
escape sequence; see
groff(7).
.
Unknown D\~commands are assumed to be device-specific.
.
Its arguments are parsed as strings; the whole information is then
sent to the postprocessor.
.
In the following command reference, the syntax element
\[la]line_break\[ra]
means a
syntactical line break
as defined in section
R Separation .
.
.
Draw B-spline from current position to offset
then to offset
if given, etc. up to
This command takes a variable number of argument pairs;
the current position is moved to the terminal point of the drawn curve.
.
.
Draw arc from current position to
with center at
then move the current position to the final point of the arc.
.
.
Draw a solid circle using the current fill color with diameter\~\c
(integer in basic units\~\c
with leftmost point at the current position; then move the current
position to the rightmost point of the circle.
.
An optional second integer argument is ignored (this allows to the
formatter to generate an even number of arguments).
.
This command is a groff extension.
.
.
Draw circle line with diameter\~\c
(integer in basic units\~\c
with leftmost point at the current position; then move the current
position to the rightmost point of the circle.
.
.
Draw a solid ellipse in the current fill color with a horizontal
diameter of\~\c
and a vertical diameter of\~\c
(both integers in basic units\~\c
with the leftmost point at the current position; then move to the
rightmost point of the ellipse.
.
This command is a groff extension.
.
.
Draw an outlined ellipse with a horizontal diameter of\~\c
and a vertical diameter of\~\c
(both integers in basic units\~\c
with the leftmost point at current position; then move to the
rightmost point of the ellipse.
.
.
Set fill color for solid drawing objects using different color
schemes; the analoguous command for setting the color of text, line
graphics, and the outline of graphic objects is
R m .
.
The color components are specified as integer arguments between 0 and
\n[@maxcolor].
.
The number of color components and their meaning vary for the
different color schemes.
.
These commands are generated by the groff escape sequences
\*[@backslash]D'F ...'
and
\*[@backslash]M
(with no other corresponding graphics commands).
.
No position changing.
.
This command is a groff extension.
.
.
.
Set fill color for solid drawing objects using the CMY color scheme,
having the 3\~color components cyan, magenta, and yellow.
.
.
Set fill color for solid drawing objects to the default fill color value
(black in most cases).
.
No component arguments.
.
.
Set fill color for solid drawing objects to the shade of gray given by
the argument, an integer between 0 (black) and \n[@maxcolor] (white).
.
.
Set fill color for solid drawing objects using the CMYK color scheme,
having the 4\~color components cyan, magenta, yellow, and black.
.
Set fill color for solid drawing objects using the RGB color scheme,
having the 3\~color components red, green, and blue.
.
.
.
The argument
must be an integer in the range -32767 to 32767.
.
0 \[<=] n \[<=] 1000
Set the color for filling solid drawing objects to a shade of gray,
where 0 corresponds to solid white, 1000 (the default) to solid black,
and values in between to intermediate shades of gray; this is
obsoleted by command
R DFg .
.
R n < 0 or n > 1000
Set the filling color to the color that is currently being used for
the text and the outline, see command
R m .
For example, the command sequence
.
mg 0 0 \n[@maxcolor]
Df -1
.
sets all colors to blue.
.