[comp.lang.postscript] font listing

zs04+@andrew.cmu.edu (Zachary T. Smith) (05/11/91)

Has anyone got a utility to print out which fonts are
intalled on a printer?

I know it's got to be the simplest program ever to write,
but I'd like to conserve my enery at it were.

Thanks!

-Zack Smith (zs04@andrew.cmu.edu)

jnp@tnds09.tele.nokia.fi (J|rgen N|rgaard) (05/13/91)

this piece does parts of it, not very nicely though

%!PS-Adobe-1.0

/ListFonts
{ 7 dict begin
    /FontForName {/Times-Roman findfont 10 scalefont setfont} def

    /Mh 20 def
    /Mv 0 def
    /Minc 15 def
    /Mind 30 def

    Mh Mv Minc add moveto
    /Times-Bold findfont 10 scalefont setfont
    (Font List:) show

    Mh Mv moveto
      FontForName

    FontDirectory {
      pop dup
      FontForName
      Mind 0 rmoveto
      50 string cvs show
      ( :" ) show 
      findfont 12 scalefont setfont
      (Sweet home Alabama) show
      FontForName
      (") show
      /Mv Mv Minc sub def
      Mh Mv moveto } forall
  end % local dict
} def
--
ORIGIN  '~jnp/stdDisclaimers';
[[--- Regards, J|rgen N|rgaard ('|' is '\o{}' in \LaTeX{})                    |
|      e-mail: jnp@tele.nokia.fi  || Telephone: +358-0-511-5671               |
|         mail: Nokia Telecommunications, PL 33, SF-02601 Espoo Finland   ---]]

bcockburn@acorn.co.uk (Bruce Cockburn) (05/15/91)

%! => &.Laser.Utils.Font.Print

/reencsmalldict 12 dict def
/ReEncodeSmall
{reencsmalldict begin
 /newcodesandnames exch def
 /newfontname exch def
 /basefontname exch def
 /basefontdict basefontname findfont def
 /newfont basefontdict maxlength dict def
 basefontdict
 {exch dup /FID ne
  {dup /Encoding eq
   {exch dup length array copy
    newfont 3 1 roll put}
   {exch newfont 3 1 roll put}
   ifelse
  }
  {pop pop}
  ifelse
 }forall
 newfont /FontName newfontname put
 newcodesandnames aload pop
 newcodesandnames length 2 idiv
 {newfont /Encoding get 3 1 roll put}
 repeat
 newfontname newfont definefont pop
 end
} bind def

/display
{ /s exch def /i exch def
  % -- s str cvs print (\n) print flush
  i -1 eq
   { vec 1 s put
     save
       displayfont /xyzzy vec ReEncodeSmall
       /xyzzy findfont mainsize scalefont setfont
       x y moveto ( ) show
     restore
     x 20 add y moveto s str cvs show
   }
   { x y moveto (&) show i 16 str cvrs show
     chars s true put
     s /.notdef ne
       { disp setfont
         x 30 add y moveto 1 string dup 0 i put show
         maintext
         x 50 add y moveto s str cvs show
       } if
   } ifelse
     /y y mainsize sub 0.5 sub def
      y 25 lt i 64 mod 63 eq or { /y 798 def /x x 110 add def
                x 510 gt {showpage /x 30 def} if
              } if
} bind def

/listallfonts {
  % prints a single page with the names of all
  % the fonts in the font directory.

  /Courier-Bold findfont 15 scalefont setfont
  /str 40 string def
  /entry 0 def
  /y 800 def

  FontDirectory {
    pop /displayfont exch def
    (\n) print
    displayfont str cvs dup print
    60 y moveto show 
    (, \() print
    entry str cvs print
    (\)) print flush
    30 y moveto entry str cvs show
    /y y 18 sub def
    /entry entry 1 add def
  } forall
  showpage
} bind def

/printallfonts {
  % prints all the fonts in the font directory on page per font

  /which 0 def
  FontDirectory {
    pop which exch mark 3 1 roll
    printentirefont
    /which which 1 add def
  } forall
} bind def

/printentirefont {
  % Takes a fontname and an optional number on the stack
  % i.e. mark 99 /Times-Roman printentirefont
  %      mark /Test printentirefont

  /displayfont exch def  % keep the first argument
  /mainsize 8.8 def
  /examplesize 16 def
  /headingsize 14 def
  /maintext { /Palatino-Roman findfont mainsize 1 sub scalefont setfont } bind def
  /headingtext { /Times-Bold findfont headingsize scalefont setfont } bind def
  /str 40 string def
  /vec [ 32 /.notdef ] def

  headingtext
  displayfont str cvs
  30 810 moveto dup show print

  250 810 moveto
  statusdict begin
    40 string printername show
    ( PS ) show version show ( Rev. ) show revision 20 string cvs show
  end

  counttomark 0 ne {
    str cvs
    ( \() dup show print
    dup show print
    (\)) dup show print
  } if
  cleartomark (\n) print flush
  displayfont findfont examplesize scalefont setfont
  30 135 moveto (THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG) show
  30 110 moveto (the quick brown fox jumps over the lazy dog) show
  30  85 moveto (! " # $ % & ^ ~ @ * ? | _ 0 1 2 3 4 5 6 7 8 9) show
  30  60 moveto (+ - = \( \) [ ] { } < > ` ' : ; . , / \\) show
  maintext
  save
    /disp displayfont findfont mainsize scalefont def
    /chs disp /CharStrings get def
    /chars 400 dict def
    chs { pop chars exch false put } forall
    /enc disp /Encoding get def
    /x 30 def
    /y 798 def
    0 1 255 { dup enc 2 -1 roll get display } for
    chars { {pop} {-1 exch display} ifelse } forall
    showpage
  restore
} bind def

% Insert test font here

% mark /Courier printentirefont
% mark /Times-Roman printentirefont