Although it is possible to create output in which every bit of text is explicitly positioned (e.g. using TEXTOUT), it is common for some or even all of the text in a GDI report to rely on some kind of automatic line spacing. To this end, the GDI output system maintains a virtual "cursor" (print head?) which marks the position where the next character will be output, unless some kind of explicit repositioning directive is issued first. This cursor moves horizontally (based on the character widths) as text is output, and vertically whenever a line terminator (CRLF or just LF) is processed.
The remainder of this topic discusses the various commands and parameters which determine how the vertical line spacing is calculated.
LPP in the printer ini file: The initial line spacing is determined by the combination of the LPP (lines per page) parameter in the printer ini file and the effective paper size (which may be determined at print time based on user actions and/or printer driver defaults). For example, if LPP=63, and the effective paper length (minus the physical printer margins) is 10.5 inches, the initial line spacing will be set to 1/6 inch. If there is no LPP specified in the printer ini file (or if there is no printer ini file), a default value of 66 is used for portrait and 51 for landscape. Note that unless the printer ini file also specifies PITCH=AUTO, the line spacing will be independent of the initial font size (which is determined by a FONT parameter in the printer ini file, SETFONT directives in the print file itself, or the printer driver defaults).
SETVMI: This directive in the print file overrides any previous line spacing and establishes new spacing. Note that such spacing is independent of font and paper sizes. See comments below for details on precision.
RESETLPP: This directive in the print file cancels the line spacing established by the printer ini file and/or a prior SETVMI. Once the default line spacing has been reset in this way, it will be automatically adjusted to match the natural line spacing of font of the current font (and will continue to be automatically adjusted by subsequent SETFONT directives).
SETFONT: These directives in the print file do not normally change the line spacing established by the printer ini file and/or a prior SETVMI, unless the prior line spacing has been reset by a RESETLPP directive, in which case the line spacing is adjusted to match the natural cell height (including external leading) of the font.
SETTEXTALIGN: This does not affect the line spacing, but does affect the relationship of the characters to the "cursor". Without an explicit SETTEXTALIGN directive, the cursor position is taken to be the upper left corner of the next character cell.
Comments
Prior to A-Shell 5.1.1150.0, the vertical line spacing resulting from the above factors was always rounded down to the nearest pixel of the output device. This sometimes resulted in overall vertical spacing less than anticipated. For example, if you used the combination of //SETMAPMODE,TWIPS and //SETVMI,180 to establish 8 lines per inch spacing, on a 300 DPI device, that comes to 37.5 pixels per line, which was being rounded to 37. By the bottom of the page, those half-pixels could add up to the equivalent of an entire line. But changing the DPI of the output device to 600 would have made the rounding error go away.
Starting with A-Shell build 5.1.1150.0, the line spacing is instead maintained internally in tenths of pixels and only rounded to the nearest pixel when actually positioning a line of text. This eliminates the accumulation of rounding / conversion errors as you move down the page, and makes the spacing nearly immune to changes in the device resolution (both good things) but could result in slightly different vertical spacing (i.e. more precise) vs. the prior version.