🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #3851

Re: listing fonts

#3851
From: Keith D Gregory
Date: Sat, 26 Sep 1992 19:53
99 lines
3118 bytes
In article <1992Sep22.162627.22540@bradley.bradley.edu> pwh@bradley.bradley.edu
(Pete Hartman) writes:
>
>What is a good way to get a list of fonts available?
>

Here's a piece of code to print a font listing, using the font to print its
own name (I'm posting instead of e-mailing, since this is the second time I've
done this).

-kdg

---- cut here --
%! PS-Adobe-1.0
%-----------------------------------------------------------------------------
% This program prints a list of all fonts installed in a PostScript printer,
% at 14 pt on one or more pages.
%-----------------------------------------------------------------------------
 
save
 
%-----------------------------------------------------------------------------
% A bubble sort, so that the font list looks good.
%-----------------------------------------------------------------------------
 
/BSort                        % array -- sorted_array
    {
    /arry exch def
    /alen arry length def
    /again true def
        {
        again {/again false def} {exit} ifelse
        0 1 alen 2 sub
            {
            /x1 exch def
            /x2 x1 1 add def
            arry x2 get arry x1 get lt
                {
                /again true def
                arry x1 get arry x2 get exch
                arry x2 3 -1 roll put
                arry x1 3 -1 roll put
                } if
            } for
        } loop
    arry
    }
def
 
%-----------------------------------------------------------------------------
% A function to find the scaled height of a font, from its bounding box.
%-----------------------------------------------------------------------------
 
/FontHeight                   % font -- line_height
    {
    /ix exch def
    ix /FontBBox get aload pop exch pop exch sub
    ix /FontMatrix get transform exch pop ceiling
    }
def
 
%-----------------------------------------------------------------------------
% Page-layout constants
%-----------------------------------------------------------------------------
 
/xlft  36 def
/xmid 306 def
/xrgt 612 def
/ytop 756 def
/ybot  36 def
 
%-----------------------------------------------------------------------------
% The heart of the program
%-----------------------------------------------------------------------------
 
/x xlft def
/y ytop def
 
[ FontDirectory { pop 64 string cvs } forall ] BSort
{
/fontname exch def
/thefont  fontname cvlit findfont 14 scalefont def
/fheight  thefont FontHeight def
x y moveto
thefont setfont fontname show
/y y fheight sub def
y ybot lt
    {
    x xlft eq
        {/x xmid def}
        {/x xlft def showpage}
    ifelse
    /y ytop def
    } if
}
forall
 
showpage
restore
Technical Details
Message-ID: <Bv7B9D.Exu@world.std.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!world!kdg
References: <1992Sep22.162627.22540@bradley.bradley.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.postscript
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!world!kdg
From: kdg@world.std.com (Keith D Gregory)
Subject: Re: listing fonts
Message-ID: <Bv7B9D.Exu@world.std.com>
Organization: The World Public Access UNIX, Brookline, MA
References: <1992Sep22.162627.22540@bradley.bradley.edu>
Date: Sat, 26 Sep 1992 19:53:36 GMT
Lines: 99