Next Previous Contents

2. General description

2.1 Some definitions

Some keywords are used throughout this document, which may be unknown (or known with another meaning) outside LPU. So here is a description of them:

DOT

Within LPU, all positions and distances are calculated in the unit DOT. A DOT is currently defined as a tenth of a point (1/720").

UNIT

A UNIT is an integer or float value with an optional unit.

The unit can be any of

A missing unit is interpreted as DOT.

A UNIT is always directly converted to DOTs.

NUM

Datatype T_NUM, numerical.

This is an integer value, 32bit on most systems.

FLT

Datatype T_FLT, float.

This is a float value, 64bit double on most systems.

STR

Datatype T_STR, string.

This is a text string value, the maximum length is not exactly defined at this time.

2.2 Functional description

LPU reads its commands from one or more command files, executes the commands and creates postscript code as output.

If no command files are given, commands are taken from stdin.

If no output file is specified, output is sent to stdout.

LPU requires two additional support files:

  1. a file with device specific information (see The DEV file).
  2. a file with form and label definitions (see The TAB file).

Additionally, a file with general parameters may be used (see The PAR file).

2.3 The command line

LPU is called in the following way:

  lpu { OPTION } { SOURCE-FILE }

Currently, the following options are known:

--

This option tells LPU to take commands from STDIN instead of a file; it has no effect if any SOURCE-FILEs are given on the command line.

-b

tells LPU to run in batch mode.

Within this mode, some LPU commands behave differently. The system function `$batchmode' may be used within programs to check if LPU is running in this mode, and to react in a convenient way.

-dDEVFILE

specifies a different name for the DEV file. The default name is `lpu.dev'.

-f

creates a thin frame around every label.

This is useful for test purposes or as a means to cut the label out of a plain sheet of paper.

-h

Shows a list of all known options.

-jCOUNT

tells LPU to skip the first COUNT labels on the first sheet.

This is useful if you want to continue filling a partly used sheet.

-oOUTFILE

tells LPU to send the output to file OUTFILE. If this option is missing, output is sent to STDOUT.

-pPARFILE

specifies a different name for the PAR file. The default name is `lpu.par'.

-q

makes LPU quiet.

-sSYMBOL=[VALUE]

creates a global variable SYMBOL with an optional value VALUE; the type of the variable is T_STR.

If VALUE is missing, an empty string is assigned to SYMBOL.

-tTABFILE

specifies a different name for the TAB file. The default name is `lpu.tab'.

-v[LEVEL]

specifies a debug level. LEVEL may be a number between `0' and `9', the default (if LEVEL is missing) is `1'. Without this option, or if LEVEL is `0', no debug information is created, `1' creates only little information, and `9' as much as available.

All debug information - like all error messages - are directed to stderr.

SOURCE-FILE specifies the name of an LPU command file. If the extension is missing `.lpu' is assumed.

Any number of SOURCE-FILEs may be given on the command line. They are executed in the order they are given on the command line.

If no SOURCE-FILE is given, then commands are taken from STDIN; in this case, option `--' should be used.

LPU will search for the DEV, TAB and PAR files (the original names or the names set by the options `-d', `-t' and `-p') in the following order:

2.4 The DEV file

This file contains information about the used output device. It defines paper sizes, fonts etc.

It is a pure text file, and the information is organized line by line.

Empty lines, and lines which start with a `;' are ignored.

Commands start with a `%', followed by a keyword and optional parameters.

The following commands are defined:

%Device ID TYPE COMMENT

specifies the output device.

ID is an identifier for the device.

TYPE is the type of the device. Currently, the following device types are defined:

SEQ

sequential output.

RAN

random output.

Currently, LPU requires the device type to be `RAN'.

COMMENT is a short description of the device.

%Adjust XNULL YNULL

this defines offsets for adjustment of the output device.

The values XNULL and YNULL (measured in DOT) will be added to every coordinate on the page. So a positive value shifts the output to the right and bottom, while a negative value shifts to the left and top.

The LPU distribution contains the program 'messen.lpu', which can be used to print a test sheet for measuring these offsets.

%Page ID XMAX YMAX LM RM TM BM { OPTION }

defines a new page format.

ID is a unique name for the format. XMAX and YMAX define the total size of the format in DOT.

LM, RM, TM and BM specify the left, right, top and bottom margin. These margins exclude the non-printable areas of the page.

The following options may be used to modify this definition:

.shift=XOFF,YOFF

shifts the output by XOFF dots horizontally and YOFF dots vertically.

.scale=XSCALE,YSCALE

scales the output by the given factors in horizontal and vertical direction.

.rotate=DEG

rotates the output by DEG degrees.

[Author's note: I would appreciate any sending in of other format definitions (especially for formats used outside Germany), which I will integrate into the distribution.]

%PsFont ID POINTS ATTR RELWIDTH FONT-NAME

%PsFont ID POINTS ATTR @FONT-NAME

defines a new postscript font.

ID is an internal font name, which will be used inside LPU (for example within the .style command).

POINTS defines the font size in points. If the font size is variable (as with true-type fonts), a `*' can be supplied instead.

ATTR is a list of font attributes, which may be constructed from the following set of characters:

N

normal. Disables all other attributes. May be needed as a place holder, if no other attributes are specified.

B

bold.

I

italic.

U

underlined.

RELWIDTH specifies the relative width of a character in relation to its height. This may of course only be used for mono-spaced fonts. The value is interpreted as RELWIDTH/1000 of the font height.

FONT-NAME is the name of the font within postscript.

Instead of specifying RELWIDTH and FONT-NAME, LPU can fetch these (and other) information from a afm (adobe font metric) file; if the font has proportional spacing, this is mandatory. In this case, the name of the afm file (without path and extension) must be specified with a leading `@'. The afm file will be searched using the afm path (see below).

%AfmPath PATH-TO-AFMFILE

specifies the path to the directory, where the afm files are located. Currently, only one absolute path may be given.

The distribution contains a sample `lpu.dev' file with a configuration for the HP laser-jet 6l and a standard ghostscript installation under Linux.

2.5 The PAR file

this file contains some often used definitions for LPU programs.

It is a pure text file, and the information is organized line by line.

Empty lines, and lines which start with a `;' are ignored.

Commands start with a dot, followed by a keyword and optional parameters.

The following commands are allowed within PAR files:

.defink ID INK-DEFINITION

.defpen ID PEN-DEFINITION

.defstyle ID STYLE-DEFINITION

the syntax of these commands is identical to the LPU commands with the same names, and should be looked up there.

The definitions within this file will be read by LPU before the first program instruction, so that every LPU program may rely on these definitions.

2.6 The TAB file

Basically, LPU works on forms and labels. A form is a description of the structure of a whole page on the output device. The form may contain one or more labels. The labels on a form may all look exactly the same, or may be different. Also, the position of the labels on the form may be very regular or totally chaotic.

Known form types are combined in a single database file, the so-called TAB file. This is a pure text file, which contains descriptions of forms and labels in a special syntax.

Empty lines are ignored.

Lines starting with `;' are comments and will be ignored too.

A line starting with the keyword `form' begins a new form definition. After this keyword, a unique name for the form and a known paper format (as defined in the DEV file) are required.

A `form' command may be followed by options `shift', `scale' and `rotate'. Then, usually one or more `label' commands follow. If no label command is given, the form is defined to consist of exactly one label, which takes the whole surface of the form and has the implicit name `label'.

The option `shift' moves the form by the given number of dots.

The option `scale' resizes the form by the given factors.

The option `rotate' rotates the form by the given number of degrees.

Every label on a form can be defined using the `label' command.

A label command consists of the keyword `label', followed by a label name and the width and height of the label. The label name must be unique within the form, and the width and height may be given as a DOT or UNIT value.

After a label command, the sub commands `base', `xrep' and `yrep' are allowed. If none of these subcommands is present, the label is assumed to be only once on the form, and is located in the top left corner (0,0) of the form.

The subcommand `base' specifies the position of the defined label on the surface of the form. The `base' command consists of the keyword `base', followed by the horizontal and vertical offsets of the label on the form, relative to the top left corner of the form. Width and height may be given as DOT or UNIT values.

If more than one identical label exists on the form (which may be the case with video cassette labels, visiting cards, etc.), this can be specified with the `xrep' and `yrep' commands, where `xrep' defines a repetition of the label in horizontal direction, and `yrep' does so in vertical direction.

Both commands have the same structure: the keyword is followed by a count and an offset. The count tells, how often the label exists on the form in the corresponding direction, and the offset (which may be given as a DOT or UNIT value) specifies the gap between two neighboring labels. A value of `0' means, that there is no gap between the labels.

For all positions and offsets within forms, the top left corner has the coordinate (0,0). Positive offsets point towards the right and bottom edges.


Next Previous Contents