Printing with proportional fonts

Proportional fonts are fonts in which each character occupies its natural width - i.e. a wide letter such as W occupies more space than a narrow one such as I. The alternative is a fixed pitch font, where each character occupies the same width regardless of size.

The words illicit and mammoth, which both have seven letters, look like this in a proportional font:

illicit

mammoth

but in a fixed pitch font they look like this:

illicit

mammoth

Proportional fonts are generally easier to read and more pleasing to the eye. However, certain difficulties arise when using them in forms, and in reports which contain tabulated information. If the maximum possible width is reserved for the text in each column, the report has a large amount of blank space. A 6-letter text field might be as long as WWWWWW, so this amount of space would have to be reserved for it - although in practice the text would nearly always be shorter.

A further problem arises with font height. Although all the characters for a given font size have the same height, it is common, especially in report titles, to print some text in a different size, or to mix different sizes in a single text line. This makes it impossible to specify the number of lines per page exactly.

The sections below explain how Sculptor deals with these problems so that printing with proportional fonts is as easy and as automatic as possible.


Field width

Sculptor uses the concept of a nominal character when specifying the page width and calculating the print position of an item. Each nominal character is the width of the 0 (zero) character in the current font. Each print field is assigned its width in nominal characters.

All the digits 0 to 9 have the same width in a proportional font. The average character width varies from font to font, but is usually slightly less than the width of a digit. The choice of the 0 character as the nominal character width, therefore, ensures that all numeric fields fit their assigned width, including those which contain sign and punctuation characters. Since alphanumeric characters are usually narrower, there is some extra space available to accommodate values which are wider than average.

Leading spaces in numeric fields are also the width of the “0” character, which ensures that the value is right-aligned. Spaces in alpha fields and in quoted strings retain their natural width.

Each item in a print command has a nominal width based on the number of characters and format. For example, an a20 type field has a nominal width of 20; an n4.2 field with the format “####0.00” has a nominal width of 8. If the printh command is used, the nominal width is either the field width or the field heading width, whichever is the greater.

Because the actual width of each text item varies, Sculptor maintains two print positions across the page: the real position, which is the actual width of the text printed so far, and the nominal position, which is the number of characters printed so far, multiplied by the width of a nominal character.

Sculptor has to determine when to print from the current real position, and when to move the real position to the nominal position in order to align the report in columns. In order to provide the maximum flexibility, and to enable easy modifications to programs written to use a fixed pitch font, the following rules are used:

1

A comma separator in a print list adds the value of sys.Gap to the current nominal character position, then moves the real position to the nominal position. Print items separated by commas are therefore aligned into columns automatically. See Spacing between items.

2

A semicolon separator in a print list alters neither the real nor the nominal position. The next item is printed immediately after the previous one.

3

The spc(integer) function adds the value of integer to the current nominal position, then moves the real position to the nominal position. This happens even if integer is zero. Print items separated by this function are therefore also aligned automatically into columns. The actual space generated is not proportional to integer and can vary.

4

The tab(integer) function sets the nominal position to integer (starting from 0) and the moves the real position to the nominal position. This function can therefore be used to move to a specified nominal character position.

5

The asp(integer) function prints a number of standard (alpha) spaces - each the width of ” “. The real position is advanced by the actual width of the printed spaces.

6

The nsp(integer) function prints a number of numeric spaces - each the width of a digit, and therefore each the width of a nominal character. The real position is advanced by the actual width of the printed spaces.

7

The fit function forces a print item to fit within its nominal width, progressively reducing the font size until it fits its allocated space. The width may be specified, defaulting to the field’s natural nominal width.


EXAMPLES

The following statements print items in columns:

print field1, field2
print field1; spc(0); field2
print field1; spc(4); field2
print field1; tab(30); field2

The following statements print items continuously:

print field1; field2
print field1; asp(4); field2
print field1; nsp(4); field2
print field1::"t"; asp(1); field2

In the last example, the “t” flag is used to remove trailing spaces from an alpha field.


Page width

The use of the nominal character means that even when a proportional font is being used, the page width can be specified as a number of fixed width characters. This value is stored in the Sculptor system variable sys.PageWidth. When a value is assigned to this variable, Sculptor selects from the printer parameter file the smallest font which can accommodate this width. An alternative method of setting the font is the setfont function, which updates sys.PageWidth automatically.


Page length

The following Sculptor system variables are involved in the setting of page length:

sys.PageLength

stores the page length in lines.

sys.CharHeight

stores the current font height in device units. Read-only.

sys.LineHeight

specifies the current line height in device units.

sys.PageLength is set when a report starts, using values from the printer parameter file. It can be directly updated. It is automatically updated when sys.PageWidth is changed, but this mechanism requires all the corresponding lengths to be stored in the printer parameter file. This is inconvenient in the GUI environment, so an alternative method can be used: setting the value of sys.LineHeight. Sculptor updates sys.PageLength automatically to the correct value for that line height and the current page size.


Printer parameter files

The printer parameter files arial.s and timesnr.s, which are supplied with the Sculptor system, use proportional fonts. It is possible to use different fonts, both fixed and proportional, in the same report, by creating a suitable parameter file. See Printer parameter files.


RELATED TOPICS

Printer parameter files

Reports