Article View: comp.lang.postscript
Article #7914Fontlist utility corrected and tested
From: Jess Anderson, MACC
Date: Wed, 01 Feb 1989 17:22
Date: Wed, 01 Feb 1989 17:22
215 lines
5985 bytes
5985 bytes
In article <7509@ihlpf.ATT.COM> cem@ihlpf.ATT.COM (Malloy)
posted a typo-laden PS program apparently without any
testing of any kind (a not very generous act, despite the
usefulness of the program).
His/her preamble to it included:
> 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 ---------------------
I have corrected the typos I found and tested the program on a
LaserWriter II NTX in both the FONTLIST and FONTSHOW modes, but
without downloaded fonts, which I don't use. I also did not test
the 3-column mode. What I've tested runs correctly and is included
below.
--- cut 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
%
/printerinfo {
/str 64 string def
statusdict begin
currentdict /product known{
(Product: ) show
product show nl
}if
currentdict/printername known {
(Interpreter: ) show
str printername show nl
}if
currentdict/revision known {
(Revision: ) show
revision str cvs show nl
}if
end %statusdict
(Version: ) show
version show nl
vmstatus /maximum exch def /used exch def pop
maximum used sub str cvs show ( of ) show
maximum str cvs show ( bytes remaining) 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
{} forall
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
---cut here---
==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==
Technical Details
Message-ID:
<1162@dogie.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!uwvax!dogie!anderson@vms.macc.wisc.eduShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!uwvax!dogie!anderson@vms.macc.wisc.edu From: anderson@vms.macc.wisc.edu (Jess Anderson, MACC) Newsgroups: comp.lang.postscript Subject: Fontlist utility corrected and tested Message-ID: <1162@dogie.edu> Date: 1 Feb 89 17:22:36 GMT Sender: news@dogie.edu Distribution: na Organization: University of Wisconsin Academic Computing Center Lines: 215