SAS Institute. The Power to Know

FOCUS AREAS

Return to Universal Printing

Base SAS

Adding Hardware Fonts to SAS Universal Printers in Version 8

Contents




Introduction

This paper is for Version 8. For SAS 9.1, TrueType fonts are the preferred method. For SAS 9.2, see the TrueType fonts topic in SAS Language Reference: Concepts.

The SAS Universal PostScript, PDF, and PCL printers ship with a variety of fonts that are native to each printing format. If your printer includes a font that is not already in the SAS Registry, or if you install additional fonts on your printer, then you need to add this information to the SAS Registry to be able to use the font with the SAS output produced from these printers.

You can add new hardware fonts to a SAS Universal PostScript, PDF, or PCL printer using either specific SAS macros (supplied by SAS) or a separate, four-step process. Using the macros supplied by SAS is the easiest method.

If you choose to add hardware fonts using the macros supplied by SAS, then you can use the PCLfont.sas program for Tagged Font Metric (TFM) files and the PSfont.sas program for Adobe Font Metric (AFM) files. Both programs include comments that explain how to use the macros.

If you choose to add hardware fonts without using SAS macros, then you can use the following four-step process:

  1. Add font metrics to a SAS catalog (either the SASHELP.COREPRN catalog or the SASUSER.COREPRN catalog).
  2. Add the new font information to the master font list of the SAS Registry.
  3. Create or modify the printer or prototype entry in the SAS Registry to refer to the new font.
  4. Concatenate SASHELP and SASUSER libraries.

Note: When adding fonts to PDF printers, Step 3 is not necessary. PCL and PostScript printers require all steps.

The remainder of this sample describes how to use the four-step process to add hardware fonts to SAS Universal Printers. Examples of this process are also provided.




Step by Step

Step 1: Add the font metrics information to a SAS catalog.

The metric data that describes a printer font is stored in font metric files. Specifically, these files describe the properties of a font independent of what the characters actually look like. For example, The files contain

Font metric files are supplied by the printer manufacturer or font foundry. To locate these files, check for files with a .tfm (Tagged Font Metric) or .afm (Adobe Font Metric) extension on any diskettes or CDs that came with your printer. A PCL printer would use TFM files while a PSL (PostScript) printer or PDF reader would use AFM files.

AFM files are plain text files that you can inspect easily. TFM files are binary files that require decoding to read.

To add font metric files to a SAS catalog:

The catalog entries are created and derived from the names of the AFM or TFM files. The file suffix will be removed and added to the front of the catalog name as a prefix. This prefix is uppercase and ends with an underscore. For example, the PostScript font metric file named Hvbo____.afm produces a catalog entry named AFM_Hvbo____ in the SASUSER.COREPRN catalog. The catalog entry name will appear under the appropriate Font ID CODE key in the registry entry for that font.

Step 2: Add the font information to the master font list and modify an existing printer prototype to refer to the new font.

You can add information to the master font list and printer prototypes in an interactive SAS session using the SAS Registry Editor. If you are adding multiple fonts or updating several printers, then you might prefer to add the information using the REGISTRY procedure instead. This procedure imports the information for all the fonts and printers from a SAS registry file (.sasxreg) that you create and then applies it to the SAS registry.

The SAS registry file that you create

The syntax for PROC REGISTRY is as follows:

PROC REGISTRY IMPORT="file-specification";

Where:

IMPORT
specifies the name of the SASXREG file that contains the registry information.

Step 3: Create a new printer using the printer prototype.

After importing the font metrics and adding font attributes to the prototype, use PROC PRTDEF or the Print Setup dialog box to create a new printer using the prototype that you just modified.

Notes: If you are adding fonts to a PDF printer, then there is no need to complete this step. However, the PDF printer will not embed the font within the document. Your PDF reader must have the font installed to avoid font substitution. Font embedding might be available with the Universal PDF printer in a later release of the SAS System.

The Print Setup dialog box is available only if Universal Printing is being used. Universal Printing is turned on by default for all operating environments except the Windows operating environment. Windows users can turn Universal Printing on by starting SAS with the -uprint -uprintmenuswitch invocation options. You can also use the PRTDEF procedure in any environment.

The complete syntax for PROC PRTDEF is provided below. In most cases, only the DATA and LIBRARY options are needed to create a new printer:

PROC PRTDEF <DATA= ><LIBRARY= SASHELP | SASUSER> <LIST><REPLACE><DELETE> <FOREIGN>;

To access the Print Setup dialog box, select File-->Print Setup from the SAS System. Once the Print Setup dialog box has opened, select New to begin the process of creating a new printer.

Step 4: Concatenate SASHELP and SASUSER Libraries.

If you create your new fonts in the SASUSER.COREPRN catalog, then you must concatenate this catalog to the SASHELP.COREPRN catalog in order to make the new fonts available to the printer. This step is necessary due to the design of the SAS registry.

To concatenate the SASHELP.COREPRN and SASUSER.COREPRN catalogs, submit the following statement in your SAS session or add this statement to your AUTOEXEC.sas file:

CATNAME sashelp.coreprn (sashelp.coreprn sasuser.coreprn);




Examples

PostScript Example: Add the font named Helvetica Bold Oblique to a PostScript printer

This example assumes that SAS is running on a Windows operating environment. The syntax for the PATH might be different on your operating environment.

Step 1: Add the font metrics file for HelveticaBoldOblique to the default SAS catalog named SASUSER.COREPRN using PROC GENFMD.

The PostScript font metrics file is c:\psfonts\Hvbo____.afm and the font will be stored in the default SASUSER.COREPRN catalog. Submit the following code in your SAS session:

PROC GENFMD PATH='c:\psfonts' TYPE=PSL;
Run;

The PostScript font metric file Hvbo____.afm will produce a catalog entry named AFM_Hvbo____ in the SASUSER.COREPRN catalog.

Step 2: Add the font information for Helvetica Bold Oblique to the SAS registry and modify the PostScript Level 2 prototype to refer to the new font.

The master font list in the SAS registry must be updated with the new font's keynames. The keynames define the new font's family, spacing, style, weight, and character set. These keyname values are font attribute codes.

Additionally, the PostScript Level 2 (Color) printer prototype must be modified in the SAS registry to make fonts available to printers created from this prototype.

To accomplish these tasks, copy and paste the following code into a file named Helbo.sasxreg:

/* Modifies the PostScript Level 2 (Color) prototype to refer to the new font */
[CORE\PRINTING\PROTOTYPES\PostScript LEVEL 2 (COLOR)\PRINTER SETUP\FONTS]
"Helvetica" = link:"\\CORE\\PRINTING\\PSL\\FONTS\\Helvetica"

/* Adds the font definition to the master font list for PostScript */
[CORE\PRINTING\PSL\FONTS\Helvetica] /* font attribute code for Helvetica is 2 */
"Family" = int:2 "Width" = int:2 /* font attribute code for normal width is 2 */
"Spacing" = int:8 /* font attribute code for proportional spacing is 8 */
"Scale" = int:1 /* font attribute code value of 1 for Scale is a constant */
"Type" = int:1 /* font attribute code value of 1 for Type is a constant */
"Sizes" = "8,9,10,11,(12,73,2)"  /* font attribute code values for Sizes are constant */
"Western" = link:"\\CORE\\PRINTING\\PSL\\CHARACTER SETS\\Western"
[CORE\PRINTING\PSL\FONTS\Helvetica\WEIGHTS]
"Bold"=int:9
[CORE\PRINTING\PSL\FONTS\Helvetica\STYLES] "Oblique" = int:3
[CORE\PRINTING\PSL\FONTS\Helvetica\CODE\104000001]"Metrics" = "AFM_Hvbo_____"

In order to pick up the SAS registry changes, import Helbo.sasxreg by submitting the following SAS code:

PROC REGISTRY IMPORT="Helbo.sasxreg";
Run;

Step 3: Create a new printer named myps that is based on the prototype PostScript Level 2 (Color) prototype using PROC PRTDEF.

Printer definitions can be created in batch mode for an individual or for all SAS users at your site using the PRTDEF procedure. The system administrator can create printer definitions in the SAS registry and make these printers available to all SAS users at your site by using the PRTDEF procedure with the LIBRARY=SASHELP option.

Individual users can create printer definitions in the SAS registry by using the PRTDEF procedure with the LIBRARY=SASUSER option. The PRTDEF procedure reads information from a SAS data set to create a new printer. For more information about the PRTDEF procedure, see the SAS online Help.

DATA addmyps;
INPUT NAME $ 1-4 MODEL $ 5-32 DEVICE $ 33-36 DEST $ 38-47 HOSTOPT $ 48-51;
Datalines;
myps PostScript Level 2 (Color) DISK sasprt.ps mod
;
PROC PRTDEF DATA=addmyps LIBRARY=sasuser;
Run;

Step 4: Concatenate SASUSER.COREPRN to SASHELP.COREPRN.

To concatenate SASUSER.COREPRN to SASHELP.COREPRN, issue the following statement in a SAS session:

CATNAME sashelp.coreprn (sashelp.coreprn sasuser.coreprn);

You can now use the HelveticaBoldOblique font with the MYPS printer. For example:

options sysprintfont="Helvetica" bold oblique;
ods printer printer=myps;
/*Your SAS code */
ods printer close;

PCL Example: Add the font named David to the PCL5e printer

This example assumes that SAS is running on a Windows operating environment. The syntax for the PATH might be different on your operating environment.

Step 1: Add the font metrics information for the David font to the default SAS catalog called SASUSER.COREPRN using PROC GENFMD.

The PCL font metrics file is d:\pclfonts\hebrew\david.tfm. The font will be stored in a catalog named SASUSER.COREPRN. Submit the following code in your SAS session:

PROC GENFMD PATH='d:\pclfonts\hebrew' LIB=sasuser CAT=coreprn TYPE=pcl;
Run;

Step 2: Add the font information for the David font to the SAS registry and modify the PCL 5E prototype to refer to the new font.

The master font list in the SAS registry must be updated with the new font's keynames. The keynames define the new font's family, spacing, style, weight, and character set. These keyname values are font attribute codes.

The PCL 5Eprinter prototype must be modified in the SAS registry in order to make fonts available to the printers created from this prototype. In this case, the PCL5e prototype must be modified to support the David font.

To accomplish these tasks, copy and paste the following code into a file named Hebrewfonts.sasxreg:

/* Modifies the PCL 5E prototype to refer to the new font */
[CORE\PRINTING\PROTOTYPES\PCL5E\PRINTER SETUP\FONTS]
"David" = link:"\\CORE\\PRINTING\\PCL\\FONTS\\David"

/* Adds the font definition to the master font list for PCL */
[CORE\PRINTING\PCL\CHARACTER SETS\Hebrew-8]
"Description" = "Hebrew-8" "ID" = int:34
"Code" = "8H"
[CORE\PRINTING\PCL\FONTS\David]
"Family" = int:1
"Width" = int:0
"Spacing" = int:8
"Scale" = int:1
"Type" = int:0
"Sizes" = "8,9,10,11,(12,72,2)"
[CORE\PRINTING\PCL\FONTS\David\CHARACTER SETS]
"Hebrew-8" = link:"\\CORE\\PRINTING\\PCL\\CHARACTER SETS\\Hebrew-8"
[CORE\PRINTING\PCL\FONTS\David\WEIGHTS]
"Medium" = int:4
[CORE\PRINTING\PCL\FONTS\David\STYLES]
"Upright" = int:1
[CORE\PRINTING\PCL\FONTS\David\CODE\104]
"Metrics" = "TFM_DVR0000S"

In order to pick up the SAS registry changes, import HebrewFonts.sasxreg by submitting the following SAS code:

PROC REGISTRY IMPORT="HebrewFonts.sasxreg";
Run;

Step 3: Add the font named David to the PCL5e printer using the Print Setup dialog box. You can use the Print Setup menu to create or modify Universal Printers when Universal Printing is enabled as the printing mechanism for the SAS session.

  1. From the SAS pmenu, select File->Print Setup. The Print Setup dialog box appears.
  2. Select New.
  3. Provide a name and description for the new printer.

    Name: mypcl

    Description: PCL printer with Hebrew font support

  4. Select Next.
  5. Choose the printer prototype PCL 5E. This is the prototype that you modified in Step 1.
  6. Select Next.
  7. Select Next again.
  8. Select Finish to complete the creation of your new printer.

    Your new printer, mypcl, is highlighted in the Printer select list.

  9. Select Properties.
  10. Select the Font tab.

    Scroll through the list of fonts and select David in order to make David the default font.

  11. Select OK.
  12. Select OK again to close the Properties dialog box.
  13. Select OK to close the Print Setup dialog box.

Step 4: Concatenate SASUSER.COREPRN to SASHELP.COREPRN.

To concatenate SASUSER.COREPRN to SASHELP.COREPRN, issue the following statement in a SAS session:

CATNAME sashelp.coreprn (sashelp.coreprn sasuser.coreprn);

To test your new printer:

  1. From the SAS pmenu, select File->Print Setup. The Print Setup dialog box appears.
  2. From the Printer select list, select mypcl.
  3. Select Print Test Page to test your new printer.

    Your output will be created in a file called sasprt.pcl that you can then send to your printer.

  4. Select OK to close the Print Setup dialog box.



Your Turn

The developers, testers, and documentation folks that bring you Base SAS Software are very excited about the potential of these new capabilities of the SAS System. You can send electronic mail to Base.Research@sas.com with your comments.