Proportional Fonts with SAS® Software· Yes You Can!
Total Page:16
File Type:pdf, Size:1020Kb
Proportional Fonts with SAS® Software· Yes You Can! John Laing, SAS Institute (Canada) Inc. <[email protected]> Abstract be expressed in an absolute unit of measurement, u~ually inches. In producing this document, much information was obtained from These days, with the proliferation of graphical user interfaces, two Hewlett-Packard publications, peL 5 Printer Language producing presentation-quality reports is becoming a required Technical Reference Manual[l], and PCL 5 Comparison Guide[2]. feature for any software tool This paper will illustrate a technique for creating this type of report from 8AS p~ocedures. by using the 8AS macro language to insert text fonnattlUg codes mto Font Basics TITLE and FOOTNOTE statements. The code shown in the paper assumes a PCLTM 5-compatible printer such as the Hewlett Some terms and definitions you11 need to understand when Packard LaserJet™ 4, but the method of inserting printer control working with fonts are. codes should be the same no matter which printer is used. A technique for using FSFORMS to control the output on the TYPEFACE printer also be shown, as well as drawing attractive boxes will A generic name for symbols (i.e., c~aracters) haviI?~ comm.on around tabular output in both the OSJ2®and Windows™ design features. There are two mam typeface f~mlhes, sent environments. and sans-serif. The difference between the two IS the presence or absence of "tails" on the edges ofthe letters: Overview Historically, SAS has been an excellent.product for analysing T -this is a serif font data and displaying that data in either columnar or tabular formats, but has been rather weak at "prettying-up" the reports. The reason for this is simple - SAS has no easy way to handle T - this is a sans-serif font proportional fonts, which are required to do presentation-quality reports. Serif and sans-serif fonts The main reason for the problem is the way SAS deals with the printer - whether you're using a SAS procedure or DATA step, the SYMBOL SET output controls are all based on the character position within the A unique ordering of the characters in a font. Each symbol set line. This works well if the font is a fIxed-spaced one, where the is defined with a set of applications in mind. Thus, a symbol inter-character spacing is the same whatever the character, but set may have box-drawing characters, or it may have foreign fails when using a proportional font, where different characters language characters, or both. Symbol sets within ASCII and have different widths. Compare these two lines: EBCDIC platforms can contain a maximum of256 different characters. The quick brown fox jumped. STROKE. WEIGHT Describes the thickness of the strokes that make up The quick brown fox jumped. characters. Bold is an example of a stroke weight. Proportional vs. FlXed Fonts STYLE The angularity of the strokes of the characters with respect to the X-Axis. Italic is an example of a style. Notice that the first line, which is in a proportional font, is not as PITCH long as the second one, which is in a fixed-spaced font. Thus, it's Describes the number of characters printed per horizontal usually possible to get more information into the same space if a inch. It is applicable only to flXed-spaced fonts. proportional font is used. Another example illustrating the problem that SAS users POINT , . .. A unit of measurement that equals 72 mch. F~nt .hetg~t IS. encounter when using proportional fonts is columnar output: measured in points and horizontal movement Wlthln a hne IS measur~d in decipoints ( 7~O inch) on a peL 5-compatible laser pnnter. XXX. YYY <-10 spaces between. III. BBB TTT. CCC <-proportional font Laser Printer Basics xxx. yyy <-10 spaces here. To be able effectively to take advantage of the capabilities of a III. BBB laser printer, you need to understand how to control its functions. TTT, CCC <-fixed font This entails some "bits-and-bytes" knowledge of the commands available, and how they interact with each other. The problem with columns Before using the actual commands themselves, however, understanding the way the laser printer selects a font to be used is necessary. To select a font for printing, the printer needs to This example shows that using a proportional font makes it very know the following information: symbol set, spacing, height, difficult to line up columns by inserting blanks between them. pitch, style, stroke weight, typeface, and orientation. Each of This, however, is the way SAS does it, and thus there is a b~~ic these characteristics has a default value that takes effect when incompatibility between BAS and proportional fonts. To pOSItion the printer is initialized, either by powering it on, or by a software data properly when using a proportional font, the position must command. 1082 The HP4 stores font information in a font select table. For the HP4, the default is Roman-8, which is inadequate if Whenever a font control command is received by the printer, this you wish to print box-drawing characters. I suggest using the table is updated. When the time comes to print the text, the PC-8 character set, which matches the character set found on printer searches all available fonts and selects the one that most PC's. Note that Windows users will need to set SAS up slightly closely matches the select table characteristics. differently to use box-drawing characters properly - more on The printer will also prioritize these characteristics as follows: this later! To create the command to use the PC-8 symbol set, use the following SAS statement: Symbol Set High %let peS = &esc.(10U; Spacing I Pitch I SPACING Height I This command controls whether your font is proportional or Style I fIxed. To create a macro containing the command to set fixed Stroke Weight I spacing, use this SAS statement: Typeface Family I Resolution I %let fixed=&esc.(sOP; Location I For proportional spacing, use this statement: Orientation Low %let prop=&esc.(s1Pj Font selectlOn priority PITCH For the purposes of this paper, we will assume that the font is an This command controls the horizontal spacing for fixed fonts. internal one (Location), and will accept the default resolution. It will be ignored when a proportional font is selected. To set a macro variable for this command, use this statement: When the printer selects a font, it first compares the highest priority characteristic in the font select table to the corresponding %let pitch12=&esc.(s12H; characteristic for the available fonts. If only one font matches, it is selected. If multiple fonts match, the process is repeated for the The above command sets the pitch to 12. To set a different next highest priority, and so on, until, only one font remains. This pitch (16.6 for example), simply change the 12 to the desired one is then selected. number: %let pitch16=&esc.(s16.6Hj Printer Commands HEIGHT To control the laser printer, you will need to know how to build a This command controls the height of the font in points. It is printer control command. The technique shown in this paper uses SAS macro variables to store these commands. Syntactically, all ignored when a fIxed font is selected. To set a macro variable printer control commands start with the ESCAPE character, for this command, use which is the 27th character in the ASCII collating sequence (when %let htl2=&esc.(s12V; illustrating a printer command, the ESC character will be represented as a .... ). Thus, we can code a small DATA step to assign this character to a macro variable &esc: As with the PITCH command, the number can be changed to give a different height: data _null_j %let htlS=&esc.(s18V; call symputCesc', byte(27»; run; STYLE The printer commands commonly used will be described in the This command controls the angularity of the characters, as following section. well as their structure. To set a macro variable which will turn on italics, use RESET This is one of the simplest printer commands, but one that %let italic=&esc.(1S; should be used at the beginning of each report. This command To reset the printing back to normal characters, use will change all the printer settings to their power-on status. The syntax of the RESET command is %let normal=&esc.(OSj ..E Styles are specified by changing the number. Available styles include these: Note that the characters in all these printer commands are case-sensitive, and must be o upright used exactly as shown. 1 italic 4 condensed 5 condensed italic S compressed (extra condensed) To store this command in a SAS macro variable, use the 24 expanded following statement: 32 outline 64 inline %let reset=&esc.Ej 128 shadowed 160 outline shadowed You need to ensure that the periodC) follows the &esc macro variable name, to separate it from the letter E following. Style selection numbers SYMBOL SET Use this command to select the symbol set you wish to use. STROKE WEIGHT There are several available symbol sets, each of which should This command controls the thickness of the characters. It is be illustrated in the Users Manual for your particular printer. 1083 usually used for emphasis. To set a SAS macro variable to turn The Horizontal Spacing Problem on bold printing, use As noted previously, positioning data on the page must be done by %let boldon=&esc.(3Bj specifying a horizontal measurement expressed in inches, and not in columns or character position. PCL 5 provides a command to To turn off bold printing, and resume normal stroke weight, accomplish this: use +-&a#H %let boldoff'=&esc.(OB; The desired position is substituted for the #, but the units must Stroke weights fall within the range -7 to +7, with·7 being the be given in decipoints.