Article View: comp.lang.postscript
Article #7619Postscript code to display a font
From: Ian Gregory
Date: Fri, 18 Nov 1988 05:39
Date: Fri, 18 Nov 1988 05:39
71 lines
2202 bytes
2202 bytes
Here is one of my first postscript programs. It produces
a 16*16 table of all 256 characters in a given postscript
font. I have only tested it on an Apple LaserWriter. The
last line of the program does the table for the Helvetica
font. Try also looking at the Symbol font (/Symbol). I
have used this procedure in a program which looks at the
font directory, and automatically prints a table for every
font installed on the printer.
Ian Gregory
iang@plasmoid.dartmouth.edu
--------------------Cut Here---------------------------------
%!
% Generate a table of all the characters in a
% particular font. The character code is given by
% (16*row + column) where row and column are in [0, 15]
%
% Ian Gregory
% Thayer School of Engineering
% iang@plasmoid.dartmouth.edu
%
/charstring 1 string def
/x0 30 def
/y0 50 def
/ds 560 def
%
%
/putentry
{
2 copy moveto
15 exch sub 16 mul add
/charcode exch def
charstring 0 charcode put
charstring show
} def
%
% The following procedure constructs the table,
% it expects a font-key to be on the stack.
%
/fontmap
{
findfont /MainFont exch def
/MainFontName MainFont /FontInfo get /FullName get def
x0 y0 translate
ds 16 div dup scale
%
% Display the name of the font:
%
/Helvetica findfont 0.5 scalefont setfont
2 18 moveto MainFontName show
%
% Draw the grid:
%
0.005 setlinewidth
0 1 16 { 0 moveto 0 16 rlineto } for
stroke
0 1 16 { 0 exch moveto 16 0 rlineto } for
stroke
%
% Fill in the entries:
%
0.25 0.25 translate
MainFont 0.5 scalefont setfont
0 1 15 { /y exch def 0 1 15 { y putentry } for } for
showpage
} def
%
% Here is an example
%
/Helvetica fontmap
Technical Details
Message-ID:
<10987@dartvax.Dartmouth.EDU>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!bu-cs!dartvax!plasmoid.dartmouth.edu!iangShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!bu-cs!dartvax!plasmoid.dartmouth.edu!iang From: iang@plasmoid.dartmouth.edu (Ian Gregory) Newsgroups: comp.lang.postscript Subject: Postscript code to display a font Message-ID: <10987@dartvax.Dartmouth.EDU> Date: 18 Nov 88 05:39:59 GMT Sender: news@dartvax.Dartmouth.EDU Reply-To: iang@plasmoid.dartmouth.edu (Ian Gregory) Organization: Dartmouth College Lines: 71