Changing Fonts

This chapter discusses how to:

Click to jump to parent topicSetting Fonts

To select a font in SQR for PeopleSoft, use the DECLARE-PRINTER and ALTER-PRINTER commands. The DECLARE-PRINTER command sets the default font for the entire report. The ALTER-PRINTER command changes the font anywhere in the report and the change remains in effect until the next ALTER-PRINTER.

To set a font for the entire report, use ALTER-PRINTER, which is not printer-specific, at the beginning of the program. If you are writing a printer-independent report, the attributes that you set with DECLARE-PRINTER take effect only when you print your report with the printer that you specify with the TYPE argument. To specify a printer at print time, use the -PRINTER:xx command-line flag.

See Also

ALTER-PRINTER

DECLARE-PRINTER

Click to jump to parent topicPositioning Text

In SQR for PeopleSoft, you position text according to a grid. That grid is set by default to 10 characters per inch and 6 lines per inch, but you can give it another definition by altering the CHAR-WIDTH and LINE-HEIGHT parameters of the DECLARE-LAYOUT command.

Note, however, that character grid and character size function independently of one another. Fonts print in the size that is set by DECLARE-PRINTER or ALTER-PRINTER, not the size that is defined by the grid. A character grid is best used for positioning the first character in a string. It can express the width of a string only in terms of the number of characters that it contains, not in an actual linear measurement, such as inches or picas.

When you use a proportionally spaced font, the number of letters that you print may no longer match the number of character cells that the text actually fills. For example, in the following sample code, the word Proportionally fills only 9 cells, although it contains 14 letters.

When you print consecutive text strings, the actual position at the end of a string may differ from the position that SQR assumes according to the grid. For this reason, concatenate consecutive pieces of text and print them as one.

For example, don't write code like this:

alter-printer font=5 ! select a proportional font print &first_name () ! print first name print ' ' () ! print a space print &last_name () ! print the last name alter-printer font=3 ! restore the font

Instead, write code like this:

alter-printer font=5 ! select a proportional font ! concatenate the name let $full_name = &first_name || ' ' || &last_name print $full_name () ! print the name alter-printer font=3 ! restore the font

The WRAP and CENTER options of the PRINT command also require special consideration when used with proportional fonts. They both calculate the text length based on the character count in the grid, which is not the same as its dimensional width.

Look at the sample program. It contains a list of reminders from the reminders table. It is printed in a mix of fonts: Times Roman in two different sizes, plus Helvetica bold.

Program ex14a.sqr begin-setup declare-layout default paper-size=(10,11) end-declare end-setup begin-program do main end-program begin-procedure main ! Set Times Roman as the font for the report alter-printer font=5 point-size=12 begin-select remind_date (,1,20) edit 'DD-MON-YY' reminder (,+1) wrap 60 5 position (+2) from reminders end-select end-procedure ! main begin-heading 7 print $current-date (1,1) Edit 'DD-MON-YYYY' page-number (1,60) 'Page ' ! Use large font for the title alter-printer font=5 point-size=24 print 'Reminder List' (3,25) ! Use Helvetica for the column headings alter-printer font=4 point-size=12 print 'Date' (6,1) bold print 'Reminder' (6,22) bold graphic (6,1,66) horz-line ! Restore the font alter-printer font=5 point-size=12 end-heading

The report uses the default layout grid of 10 characters per inch and 6 lines per inch, both for positioning the text and for setting the length of the solid line.

The font is set at the beginning of the main procedure to font 5, which is Times Roman. The point size is set to 12. In the HEADING section, its size is set to 24 points to print the title.

The column headings are set to 12-point Helvetica with the ALTER-PRINTER FONT=4 POINT-SIZE=12 command. The BOLD option of the PRINT command specifies that they are printed in bold.

A solid line is under the column headings. Note that it is positioned at line 6, the same as the column headings. SQR draws the solid line as an underline. At the end the HEADING section, the font is restored to Times Roman.

In an SQR program, the report heading is performed after the body. A font change in the heading does not affect the font that is used in the body of the current page, although it changes the font that is used in the body of subsequent pages. Keep track of your font changes and return fonts to their original settings in the same section in which you change them.

Positioning the title requires careful coding. The CENTER option of the PRINT command does not work because it does not account for the actual size of the text. Instead, position the title by estimating its length. In this case, the title should start 2 1/2 inches from the left margin. The character coordinates are (3,25), which are line 3, character position 25. Remember that the character grid that is used for positioning assumes 10 characters per inch. Therefore, 25 characters is 2 1/2 inches.

Click to jump to parent topicUsing the WRAP Option

The WRAP option of the PRINT command prints the text of the reminder column. This option wraps text based on a given width, which is 60 characters in the sample program.

The WRAP option works only on the basis of the width that is given in the character grid. It does not depend on the font.

Text that is printed in Times Roman takes about 30–50 percent less space than the same text in Courier (the default font, which is a fixed-size font). This means that a column with a nominal width of 44 characters (the width of the reminder column) can actually hold as many as 66 letters when it is printed in the Times Roman font. To be conservative, specify a width of 60.

The other argument of the WRAP option is the maximum number of lines. Because the reminder column in the database is 240 characters wide, at 60 characters per line, no more than five lines are needed. Remember, this setting specifies only the maximum number of lines. SQR does not use more lines than necessary.

SQR calculates the maximum number of characters on a line by using the page dimensions in the DECLARE-LAYOUT command (the default is 8 1/2 inches wide). In the sample program, 8 1/2 inches minus the inch that is used in the margins is 7 1/2 inches, or 75 characters at 10 characters per inch (CPI). Printing 60 characters starting from position 22 could exceed this maximum and cause an error or undesirable output. To avoid this error, define the page as wider than it actually is. This definition is given by the argument PAPER-SIZE=(10,11) in the DECLARE-LAYOUT command.