QDEVICE Procedure

Example 5: Generate a Font Report

Features:

PROC QDEVICE statement options: REPORT=, OUT=

PRINTER statement

Details

The first example generates a report of all the printer-resident and system fonts available for the printer. The results are written to the WORK.MYFONTS data set.
The second example is a SAS program that uses a macro, the DATA step, and the PRINT procedure to create a list of fonts for devices.

Program

proc qdevice report=font out=myfonts; 
  printer 'postscript level 2'; 
run;

Output

The following output shows the report as it appears in the Viewtable window.
FONT report for postscript printer

Program

/* Macro FONTLIST - Report fonts supported by a device */

%macro fontlist(type, name);
proc qdevice report=font out=fonts;
   &type &name;
   var font ftype fstyle fweight;
run;
data; 
   set fonts;
   drop ftype;
   length type $16;
   if ftype = "System"
     then do;
	    if substr(font,2,3) = "ttf" then type = "TrueType";
	      else if substr(font,2,3) = "at1" then type = "Adobe Type1";
	      else if substr(font,2,3) = "cff" then type = "Adobe CFF/Type2";
	      else if substr(font,2,3) = "pfr" then type = "Bitstream PFR";
	      else type = "System";
	    if type ^= "System" then font = substr(font,7,length(font)-6);
	      else if substr(font,1,1) = "@" then font = substr(font, 2,length(font)-1);
       end;
       else type = "Printer Resident";
run;
proc sort;
   by font;
run;
title "Fonts Supported by the %upcase(&name) &type";

proc print label;
   label fstyle="Style" fweight="Weight" font="Font" type="Type";
run;
%mend fontlist;

%fontlist(device, pcl5c)

Program Description

Create the macro fontlist.The %macro statement begins the macro. The input to the macro is the type, whether it is a device or printer, and the name of the device or printer.
/* Macro FONTLIST - Report fonts supported by a device */

%macro fontlist(type, name);
Create a data set, fonts, for the device.The macro input variables, type and name, are used to create a Font report using the QDEVICE procedure. The output is written to the data set fonts.
proc qdevice report=font out=fonts;
   &type &name;
   var font ftype fstyle fweight;
run;
Categorize the font type.Fonts can be a type System, TrueType, Adobe Type1, Adobe CFF/Type2, Bitstream PFR, or Printer Resident.
data; 
   set fonts;
   drop ftype;
   length type $16;
   if ftype = "System"
     then do;
	    if substr(font,2,3) = "ttf" then type = "TrueType";
	      else if substr(font,2,3) = "at1" then type = "Adobe Type1";
	      else if substr(font,2,3) = "cff" then type = "Adobe CFF/Type2";
	      else if substr(font,2,3) = "pfr" then type = "Bitstream PFR";
	      else type = "System";
	    if type ^= "System" then font = substr(font,7,length(font)-6);
	      else if substr(font,1,1) = "@" then font = substr(font, 2,length(font)-1);
       end;
       else type = "Printer Resident";
run;
Sort the font data set by the font name.
proc sort;
   by font;
run;
Print the fonts for a device or printer.
title "Fonts Supported by the %upcase(&name) &type";

proc print label;
   label fstyle="Style" fweight="Weight" font="Font" type="Type";
run;
End the macro.
%mend fontlist;

Use the macro &fontlist to create and output data set for the PCL5c device.
%fontlist(device, pcl5c)

Output

A Partial View of the Fonts Supported by the PCL5c Device
A Partial View of the Fonts Supported by the PCL5c Device