[comp.lang.postscript] Font Listing Program

cem@ihlpf.ATT.COM (Malloy) (01/31/89)

     The following is taken from 'PC Publishing' February 1989.  It
is posted without permission and without any testing of the program.
I will test the program on my Varityper VT600+ printer within the
next few days.

     I am posting as a service to other subscribers to 'PC Publishing'.
If you don't read the mag, then you shouldn't save this program.  On
the other hand, if you don't read the mag, I cannot stop you from
saving the program.  If you have any fixes for any of the possible
typos, mail them to me.

--------------------- Copyright 1988 PC Publishing ---------------------


                   Display PostScript Printer Fonts

     Our PostScript expert offers a program for displaying all
available type faces resident in a PostScript printer or add-on
PostScript controller.

By Ross Smith

     I would like very much to take credit for the PostScript program
that follows and bears my name - or should I say, a name that is the
same as my own.  Unfortunately, I cannot.  The program was written by
my very capable son, who would never let me get by with taking credit,
anyway.  So I am obliged to give credit where credit is due -
reluctantly, I might add, for this is one nifty program that no one
using a PostScript printer should be without.

     Actually, FONTLIST.PS is three programs in one, all of which are
designed primarily to apprise the user of what type faces - internal
and downloaded - are resident in any PostScript printer or add-in
PostScript controller.  The list is bubble sorted, and displayed in a
single Helvetica type face, which enables the program to run very
quickly on any PostScript printer.  FONTLIST is intended to be used to
report quickly the exact nomenclature of each type face - which is
essential for anyone doing PostScript programming.  Downloaded type
faces are distinguished from resident type faces with an asterisk, so
they can be quickly identified.  The program also provides some useful
information about the printer and PostScript interpreter, and memory
still unsued.

     In an second iteration, FONTSHOW.PS displays the same information
as FONTLIST, except that the faces themselves are displayed.  This can
be used to determine which type face would be appropriate for any job.
Because it takes the PostScript interperter much longer to make all
the necessary type face changes, FONTSHOW should be run infrequently.

     In the third iteration, FONT3COL.PS modifies FONTLIST or FONTSHOW
to display the fonts in three columns in landscape mode.  FONT3COL is
designed to be used with an interperter that can access a large number
of type faces from a hard disk, such as the EiconScript interperter
from Eicon Technology, which can currently access up to 100 typefaces.
There are five instructions that must be modified or added to FONTLIST
or FONTSHOW to obtain FONT3COL, all of which are found in the last
column of the program, near the asterisks. We also recommend deleting
the "footnote" command line near the bottom of the program when
FONT3COL is used with an interperter that does not require font
downloading.

     For downloading type face outlines, we use a batch file we call
PSDL.BAT, which looks like this:

echo off
rem psdl.bat 6/15/88 ross smith
:loop
if//==/%1/goto exit
echo Downloading %1
echo serverdict begin 0 exitserver lpt1:
copy c:\psfonts\%1+c:\psfonts\ctrl_d/a lpt1: null:
shift
goto loop
:exit
echo Done

The file CTRL_D is simply a file with a ^D.
LPT1: can be changed to reflect the proper parallel or serial post.

     PSDL can download ant number of type faces entered on the command
line, in the format PSDL CWPQ.PFA, CXPQ.PFA, etc.  Or, typefaces that
are downloaded routinely can be placed in another batch file called,
say, GALLIARD.BAT, where they can be easily downloaded each time they
are required by simply specifying the name of the batch file.  For
instance, the command GALLIARD would send the following string found
in GALLIARD.BAT;

   PSDL CUPQ.PFA CVPQ.PFA CWPQ.PFA CXPQ.PFA

     The same string can be placed at the end of the AUTOEXEC.BAT file
to download a standard set of type faces each time the computer is
booted.

============================== Snip Here ==============================
%!PS-Adobe-2.0
%%Title: fontlist.ps
%%Creator: Ross Smith
%%Freation date: 4 November 1988
%%For: Pc Publishing
%%Copyright (C) 1988 Ross Smith
%%End Comments
%
% procedures
%
% housekeeping procedures
/SaveOne save def
/Workdict 128 dict def
Workdict begin
statusdict/jobname (Fontlist 1.0) put
% prologue
% Program procedure
/bdef {
    bind def
}bind def

% nl
% usage: -nl-
%
% move the currentpoint to the next line
% if the new line would print below the bottom margin
% begin a new column
%
/nl{
    currentpoint exch pop
    dup
    % if
    bottommargin sub 0 ge
    { % then
        leftmargin exch
        pointsize 2 add sub
        moveto
    }
    { % else
        pop
        /leftmargin leftmargin columnwidth add def
        leftmargin topmargin moveto
    } ifelse
} bdef

% printerinfo
% usage: -printerinfo-
%
% display pertinent printer/controller information
%
/printerinfor {
    /str 64 string def

    statusdict begin

    currentdict /product known{
        (Product: ) show
        product show nl
    }if

    currentdict/printername known {
        (Interperter: ) show
        str printername show nl
    }if

    currentdict/revision known {
        (Revision: ) show
        revision str cvs show nl
    }if
    edn %statusdict

    (Version: ) show
    version show nl
    vmstatus/maximum exch def/used exch def pop
    maximum used sub str cvs ( of ) show
    maximum str cvs show (bytes remaning) show nl nl
}bdef
% getfonts
% usage: getfonts array
%
% gets the list of fonts available from the printer
% returns an of string values on the stack
%
/getfonts {
    /fonts FontDirectory length def
    /FontArray fonts array def
    FontDirectory
    {} for all
    0 1 fonts 1 sub {
        /i exch def
        pop
        cvlit 64 string cvs
        /fontname exch def
        FontArray i fontname put
    } for
    FontArray
} bdef

% proc: bubblesort
% usage: array bubblesort sorted array
%
% sorts the array on the stack
% places a new sorted array on the stack
%
/bubblesort {
    dup length array copy
    /v exch def
    /n v length 1 sub def

    n-1 1 {
        /i exch def
        0 1 i 1 sub {
            /j exch def
            /t1 v j get def
            /t2 v j 1 add get def
            t1 t2 gt
            {
                v j t2 put
                v j 1 add t1 put
            } if
        } for
    }for
    v
} bdef

% listfonts
% usage: array listfonts-
% display list of fonts
/listfonts {
    helvetica setfont
    fonts str cvs show (typefaces available:) show nl nl
    {
        /fontname exch def
    fontname cvn findfont/FontType get 3 eq
        {
            -4 0 rmoveto (*) show
        } if
% ***********************************
% include following instruction for FONTSHOW.PS:
%        fontname cvn findfont pointsize scalefont setfont
% ***********************************
        fontname show
        helvetica setfont
        nl
    } forall
} bdef
/footnote {
    nl
    -4 0 rmoveto
    helvetica setfont
    (*Typeface downloaded) show
    } def
% constants
% ***********
/topmargin 720 def %change 720 to 517 for 3 col
/bottommargin 75 def %change 75 to 100 for 3 col
/columnwidth 185 def %change 185 to 250 for 3 col
% ***********
/leftmargin 50 def
/pointsize 10 def
/str 64 def
/helvetica/Helvetica findfont pointsize scalefont def
/helvetica-bold/Helvetica-Bold findfont pointsize scalefont def
%% EndProlog
% main program
% 611 0 translate %use for 3 col ***********
% 90 rotate %use dor 3 col ***********
leftmargin topmargin moveto
helvetica-bold setfont
printerinfo     % print printer/interperter information
getfonts        % get the list of fonts
bubblesort       % sort the list
listfonts       % display list of fonts
footnote        % display downloaded message
showpage        % print the page
%% Trailer
statusdict/jobname () put
end % Workdict
SaveOne restore
%% EOF

allanh@sco.COM (Allan J. Heim) (02/03/89)

Well, I tried running the fontlist program from PC Publishing (which I
_do_ read), as posted in this newsgroup, and the thing would make my
LaserWriter II NTX print hundreds of pages of the following:

ERROR: undefined
OFFENDING COMMAND:  [some random character or characters would go here]

STACK:

...and so on.  Yes, I removed the mail header of the program, so the
beginning of the file looks like:

%!PS-Adobe-2.0
%%Title: fontlist.ps
%%Creator: Ross Smith
%%Freation date: 4 November 1988
%%For: Pc Publishing
%%Copyright (C) 1988 Ross Smith
%%End Comments
%

...and the end of the file looks like:

%% Trailer
statusdict/jobname () put
end % Workdict
SaveOne restore
%% EOF

Am I doing something wrong?  Or did somebody not test this thing
before publishing it?
-- 
allanh@sco.COM              ...{decvax!microsoft,ucbvax!ucscc,uunet}!sco!allanh

anderson@vms.macc.wisc.edu (Jess Anderson, MACC) (02/04/89)

In article <2216@scolex.sco.COM>, allanh@sco.COM (Allan J. Heim) writes...

]Well, I tried running the fontlist program from PC Publishing (which I
]_do_ read), as posted in this newsgroup, and the thing would make my
]LaserWriter II NTX print hundreds of pages of the following:
] 
]ERROR: undefined
]OFFENDING COMMAND:  [some random character or characters would go here]
] 
]STACK:
] 
]....and so on.  Yes, I removed the mail header of the program, so the
]beginning of the file looks like:
] 
]%!PS-Adobe-2.0
]%%Title: fontlist.ps
]%%Creator: Ross Smith
]%%Freation date: 4 November 1988
]%%For: Pc Publishing
]%%Copyright (C) 1988 Ross Smith
]%%End Comments
[...]
]Am I doing something wrong?  Or did somebody not test this thing
]before publishing it?

I did not find *those* errors, because when I first tried 
the program, I had already loaded the ehandler.ps from 
Adobe, which promptly revealed a series of typos and other
problems.  That day I posted the corrections I had made,
with remarks that I had not tested the downloaded fonts
or 3-column aspects.  The two other modes of the program
worked fine on my LW II NTX.

I'm sorry, but I do not have the corrected machine-readable
in my home machine (it's at the office), but I have an 
uncorrected copy at home *and* a corrected listing.  I
will post that if someone asks, but be forewarned that I
have no laser printer at home and cannot actually test
here.

Email me if you'd like to have it.


==Jess Anderson===Academic Computing Center=====Univ. Wisconsin-Madison=====
| Work: Rm. 2160, 1210 West Dayton St., Madison WI 53706, Ph. 608/263-6988 |
| Home: 2838 Stevens St., 53705, 608/238-4833   BITNET: anderson@wiscmacc  |
==ARPA: anderson@macc.wisc.edu========UUCP:{}!uwvax!macc.wisc.edu!anderson==

cem@ihlpf.ATT.COM (Malloy) (02/06/89)

In article <2216@scolex.sco.COM>, allanh@sco.COM (Allan J. Heim) writes:
> Well, I tried running the fontlist program from PC Publishing (which I
> _do_ read), as posted in this newsgroup, and the thing would make my
> LaserWriter II NTX print hundreds of pages of the following:
> 
[STUFF DELETED]
> 
> Am I doing something wrong?  Or did somebody not test this thing
> before publishing it?


Subject: Font Listing Program
Date: 30 Jan 89 19:54:01 GMT

     The following is taken from 'PC Publishing' February 1989.  It
is posted without permission and without any testing of the program.
I will test the program on my Varityper VT600+ printer within the
next few days.

I repeat:


     It is posted without permission and without any testing of the
program.

     I have found a few of the typos my self.  Here is a diff.  There
is still at least one bug left since I get nothing from my VT600.

$ diff fontlist.orig fontlist.ps
4,5c4,5
< %%Freation date: 4 November 1988
< %%For: Pc Publishing
---
> %%Creation date: 4 November 1988
> %%For: PC Publishing
51c51
< /printerinfor {
---
> /printerinfo {
70c70
<     edn %statusdict
---
>     end %statusdict
76c76
<     maximum str cvs show (bytes remaning) show nl nl
---
>     maximum str cvs show (bytes remaining) show nl nl
88c88
<     {} for all
---
>     {} forall
122c122
<     }for
---
>     } for
167c167
< % 90 rotate %use dor 3 col ***********
---
> % 90 rotate %use for 3 col ***********
$



Clancy Malloy
AT&T Bell Labs
att!ihlpf!cem

anderson@vms.macc.wisc.edu (Jess Anderson, MACC) (02/07/89)

In article <7596@ihlpf.ATT.COM>, cem@ihlpf.ATT.COM (Malloy) writes...

]Subject: Font Listing Program
]Date: 30 Jan 89 19:54:01 GMT

]I repeat:

]     It is posted without permission and without any testing of the
]program.
] 
]     I have found a few of the typos my self.  Here is a diff.  There
]is still at least one bug left since I get nothing from my VT600.

Additional corrections:

Line 62:   Interpreter is misspelled.

Line 75:   missing show, should read
           maximum used sub str cvs show ( of ) show

Line 76:   missing blank:
           ( bytes remaining)

Line 110:  missing blank:
           n -1 1 {

Line 131:  missing blank:
           ( typefaces available:)

==Jess Anderson===Academic Computing Center=====Univ. Wisconsin-Madison=====
| Work: Rm. 2160, 1210 West Dayton St., Madison WI 53706, Ph. 608/263-6988 |
| Home: 2838 Stevens St., 53705, 608/238-4833   BITNET: anderson@wiscmacc  |
==ARPA: anderson@macc.wisc.edu========UUCP:{}!uwvax!macc.wisc.edu!anderson==