Classic Computer Magazine Archive COMPUTE! ISSUE 139 / APRIL 1992 / PAGE 58

Fun with fonts. (Column)
by Mark Minasi

Last time, we got started with the basics of using the Hewlett-Packard Printer Control Language (HPPCL.) We created a couple of useful batch files to force the printer to do a page eject and to reset the printer.

This month, we'll see how to shift the printer from the usual 12-point Courier to the smaller Linprinter typeface, allowing us to print wide spreadsheets or files.

To do that, we'll have to understand how to choose laser fonts--that's our goal for this month. First, we'll get some terminology out of the way, take a look at the relevant PCL commands, and then build a batch file.

Courier Isn't a Font

My friend Jane Mitchell, the Laser Jet expert, says "You can always tell a Laser Jet novice. She calls Courier a font." Courier isn't a font. (Jane is a printer snob.) It's a typeface, at least in HP terminology. Suppose you've printed a document using the Courier, err, typeface--that's all just one font, right? Wrong. You change the font if you use boldface, italics, different sizes, or go to landscape mode, to name just a few possibilities.

Fonts are described by eight attributes: orientation (portrait or landscape), symbol set (don't worry about this one just yet), spacing (fixed or proportional), pitch (width or characters), points (height of characters,) style (upright vs italic), stroke weight (light, normal, boldface), and typeface (Courier, Times Roman, and so on).

Orientation just refers to whether the text prints across the width of the page (as with the text that you're reading now), called portrait mode, or up the length of the page, called landscape mode. Orientation is selected with the &I3O code sequence, where # equals 0 for portrait or 1 for landscape. (I'll use as my shorthamd forr the ESCAPE code in this article.) Note that's an ampersand followed by a lowercase L, not the numeral 1. The ending character is an uppercase letter O, not a zero.

Symbol set dictates how particular computer (ASCII) codes relate to particular letters. For example, the ASCII code for A is 65. But what if the printe were to print Greek or Japanese? Then being able to print an A would be of no value, so 65 would correspond to some other character. That's what symbol sets describe. In most cases, you'll choose the IBM-US symbol set, also known as PC-8. This symbol set includes the IBM box-drawing characters.

A symbol set is selected in software with the sequence (### sequence, where ### is the symbol set ID. The IDs for Roman-8 and IBM-US are 8U and 10U, respectively. Check your font documentation for the symbol sets of the fonts that you've purchased. You can also find out the symbol sets on an LaserJet II by taking the printer offline and typing PRINT FONTS/TEST.

Spacing allows you to specify either fixed spacing, as in a typewriter's printing, or proportional spacing, as in this text where smaller characters take up less space than larger characters. In fixed spacing, all characters take up the same amount of space, which must be the amount required by the largest character in the character set. The escape sequence is (s#P, where # equals 0 of fixed, and 1 for proportional.

Pitch is the width of a character. Note that pitch is only used for fixed-spaced fonts--you'd never specify pitch when selecting a proportionally spaced font. Pitch is measured in characters per inch. Courier typefaces are typically 10 or 12 pitch, line printer faces usually have a pitch of 15 or 16.6. Pitch is selected with the (s##.##H sequence, where ##.## is the pitch. To select a 16.6-pitch font, use (s16.6H. The common 10-pitch Courier could be selected with (s10H. When specifying decimal values, don't use more than two decimal places.

Height is sometimes called the font's points because height is measured in points. A point is 1/72 of an inch. Height is reported in the font printout as point size. It's selected with the (s##.##V sequence. For example, the 10-point type used in this text could be selected with the (s10V sequence.

Style indicates whether the font is upright or italic. (s#S sets this, where # is 0 for upright or 1 for italic. Note that this doesn't direct the printer to italicize an existing upright font--the printer isn't capable of that. I make that point because people get confused about it. These commands can't change existing fonts--they only select fonts that are already in the printer. If no font matches the criteria--tough. Beginners often think that the series II printers will make a font with an upright style into a font with an italic style; they don't realize that you must create (or buy) a font that has an italic style. Only then, once it's been downloaded to the printer, can you issue a font-select command that includes a request for italic style.

Stroke Weight specifies whether to select a font that is lightly drawn, normal, or boldface. Activated with the (s#B sequence, where cide: orientation, symbol set, spacing, width, height, style, and (finally) typeface.

So the laser has a choice--it can match orientation and miss typeface (that's the portrait Lineprinter), or it can match typeface and miss orientation (tha's the landscape Courier). As orientation is more important, it'll give you the portrait Lineprinter.

IID and Later Printers

The series IID and later printers have an extra feature that the series II doesn't--they can rotate fonts. You needn't worry about whether a font is landscape or portrait. Just specify whether you want portrait or landscape.

You need to understand the difference. The series II uses orientation as a means to narrow down which printer font to use. The IIP and IID use this information as a command about whether or not to rotate an already selected font. That means that IID and IIP font-selection strings look like the II commands with one difference--the orientation part goes at the end of the string.

That means that the previous font selection example would look like the following on the IID or IIP: (10U (s1p12vsb5T &10O.

Let's finish off with what we came here to do in the first place: set up the laser to print Lineprinter. The Lineprinter font has the following characteristics: portrait orientation, symbol set PC-8, fixed spacing, pitch of 16.67 characters per inch, height of 8.5 points, upright, normal weight, and Lineprinter typeface. That adds up to a command string of &10O(10u< ESC>(s0p16.67h8.5v0sb0t.

Whew! I keep that in a file I call SMALLPRT.TXT, and I have an accompaying SMALLPRT.BAT that shoots it out to the printer.