home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Actualizar / Impressora_PDF / converter.exe / GPLGS / prfont.ps < prev    next >
Text File  |  2002-07-11  |  7KB  |  245 lines

  1. %!
  2. %%Creator: Eric Gisin <egisin@waterloo.csnet>
  3. %%Title: Print font catalog
  4. % Copyright (c) 1986 Eric Gisin
  5. % Copyright (C) 1992 Aladdin Enterprises, Menlo Park, CA
  6. %   Modified to print all 256 encoded characters.
  7. % Copyright (C) 1993 Aladdin Enterprises, Menlo Park, CA
  8. %   Modified to print unencoded characters.
  9. % Copyright (C) 1994 Aladdin Enterprises, Menlo Park, CA
  10. %   Modified to always create 256-element Encoding vectors.
  11. % Copyright (C) 1995 Aladdin Enterprises, Menlo Park, CA
  12. %   Modified to print more than 128 unencoded characters.
  13. % Copyright (C) 1996 Aladdin Enterprises, Menlo Park, CA
  14. %   Modified to leave a slightly wider left margin, because many H-P
  15. %     printers can't print in the leftmost 1/4" of the page.
  16. %   Modified to print unencoded characters in any font that has CharStrings.
  17. % Copyright (C) 1999 Aladdin Enterprises, Menlo Park, CA
  18. %   Modified to sort unencoded characters.
  19. % Copyright (C) 2000 Aladdin Enterprises, Menlo Park, CA
  20. %   Modified to print CIDFonts as well as fonts.
  21. %   O(N^2) sorting replaced with O(N log N).
  22. % Copyright transferred 2000/09/15 to artofcode LLC.  Send any questions to
  23. %   bug-gs@ghostscript.com.
  24.  
  25. % $Id: prfont.ps,v 1.6 2002/07/11 02:54:22 lpd Exp $
  26.  
  27. % Example usages at bottom of file
  28.  
  29. /#copies 1 def
  30. /min { 2 copy gt { exch } if pop } bind def
  31.  
  32. /T6 /Times-Roman findfont 6 scalefont def
  33. /Temp 64 string def
  34. /Inch {72 mul} def
  35. /Base 16 def    % char code output base
  36. /TempEncoding [ 256 { /.notdef } repeat ] def
  37.  
  38. % Sort an array.  Code used by permission of the author, Aladdin Enterprises.
  39. /sort {            % <array> <lt-proc> sort <array>
  40.     % Heapsort (algorithm 5.2.3H, Knuth vol. 2, p. 146),
  41.     % modified for 0-origin indexing. */
  42.   10 dict begin
  43.   /LT exch def
  44.   /recs exch def
  45.   /N recs length def
  46.   N 1 gt {
  47.     /l N 2 idiv def
  48.     /r N 1 sub def {
  49.       l 0 gt {
  50.     /l l 1 sub def
  51.     /R recs l get def
  52.       } {
  53.     /R recs r get def
  54.     recs r recs 0 get put
  55.     /r r 1 sub def
  56.     r 0 eq { recs 0 R put exit } if
  57.       } ifelse
  58.       /j l def {
  59.     /i j def
  60.     /j j dup add 1 add def
  61.     j r lt {
  62.       recs j get recs j 1 add get LT { /j j 1 add def } if
  63.     } if
  64.     j r gt { recs i R put exit } if
  65.     R recs j get LT not { recs i R put exit } if
  66.     recs i recs j get put
  67.       } loop
  68.     } loop
  69.   } if recs end
  70. } def
  71.  
  72. % do single character of page
  73. % output to rectangle ll=(0,-24) ur=(36,24)
  74. /DoGlyph {    % C, N, W set
  75.  
  76.   % print code name, width and char name
  77.   T6 setfont
  78.   N /.notdef ne {0 -20 moveto N Temp cvs show} if
  79.   0 -12 moveto C Base Temp cvrs show (  ) show
  80.   W 0.0005 add Temp cvs 0 5 getinterval show
  81.  
  82.   % print char with reference lines
  83.   N /.notdef ne {
  84.     3 0 translate
  85.     0 0 moveto F24 setfont N glyphshow
  86.     /W W 24 mul def
  87.     0 -6 moveto 0 24 lineto
  88.     W -6 moveto W 24 lineto
  89.     -3 0 moveto W 3 add 0 lineto
  90.     0 setlinewidth stroke
  91.   } if
  92. } def
  93. /DoChar {
  94.   /C exch def
  95.   /N F /Encoding get C get def
  96.   /S (_) dup 0 C put def
  97.   /W F setfont S stringwidth pop def
  98.   DoGlyph
  99. } def
  100. /CIDTemp 20 string def
  101. /DoCID {
  102.   /N exch def
  103.   /C N def
  104.   /W F setfont gsave
  105.     matrix currentmatrix nulldevice setmatrix
  106.     0 0 moveto N glyphshow currentpoint pop
  107.   grestore def
  108.   DoGlyph
  109. } def
  110.  
  111. % print page title
  112. /DoTitle {
  113.   /Times-Roman findfont 18 scalefont setfont
  114.   36 10.5 Inch moveto FName Temp cvs show ( ) show ((24 point)) show
  115. } def
  116.  
  117. % print one block of characters
  118. /DoBlock {    % firstcode lastcode
  119.   /FirstCode 2 index def
  120.   1 exch {
  121.     /I exch def
  122.     /Xn I FirstCode sub 16 mod def /Yn I FirstCode sub 16 idiv def
  123.     gsave
  124.     Xn 35 mul 24 add Yn -56 mul 9.5 Inch add translate
  125.     I DoCode
  126.     grestore
  127.   } for
  128. } def
  129.  
  130. % print a line of character
  131. /DoCharLine {    % firstcode lastcode
  132.   1 exch { (_) dup 0 3 index put show pop } for
  133. } def
  134. /DoCIDLine {    % firstcode lastcode
  135.   1 exch { glyphshow } for
  136. } def
  137.  
  138. % initialize variables
  139. /InitDoFont {    % fontname font
  140.   /F exch def        % font
  141.   /FName exch def    % font name
  142.   /F24 F 24 scalefont def
  143.   /Line0 96 string def
  144.   /Line1 96 string def
  145.   /Namestring1 128 string def
  146.   /Namestring2 128 string def
  147. } def
  148.  
  149. % print pages of unencoded characters
  150. /DoUnencoded {    % glyphs
  151.   /Unencoded exch def
  152.   /Count Unencoded length def
  153.  
  154.         % Print the unencoded characters in blocks of 128.
  155.  
  156.   0 128 Unencoded length 1 sub
  157.    { /BlockStart 1 index def
  158.      dup 128 add Unencoded length .min 1 index sub
  159.      Unencoded 3 1 roll getinterval TempEncoding copy
  160.      /BlockEncoding exch def
  161.      /BlockCount BlockEncoding length def
  162.      save
  163.      F /Encoding known {
  164.        F length dict F
  165.     { 1 index /FID eq { pop pop } { 2 index 3 1 roll put } ifelse }
  166.        forall dup /Encoding TempEncoding put
  167.        /* exch definefont
  168.        /F exch def
  169.        /F24 F 24 scalefont def
  170.        /BlockStart 0 def
  171.      } if
  172.  
  173.      DoTitle (, unencoded characters) show
  174.      BlockStart dup BlockCount 1 sub add DoBlock
  175.      F 10 scalefont setfont
  176.      36 2.4 Inch moveto
  177.     0 32 BlockCount 32 sub 224 .min {
  178.       0 -0.4 Inch rmoveto gsave
  179.       dup 31 add BlockCount 1 sub .min
  180.       exch BlockStart add exch BlockStart add DoLine
  181.       grestore
  182.     } for
  183.      showpage
  184.      restore
  185.    } for
  186.  
  187. } def
  188.  
  189. % print font sample pages
  190. /DoFont {
  191.   dup findfont InitDoFont
  192.   /DoCode {DoChar} def
  193.   /DoLine {DoCharLine} def
  194.  
  195.     % Display the first 128 encoded characters.
  196.  
  197.   DoTitle (, characters 0-127) show
  198.   0 127 DoBlock
  199.   F 10 scalefont setfont
  200.   36 2.0 Inch moveto 0 63 DoLine
  201.   36 1.5 Inch moveto 64 127 DoLine
  202.   showpage
  203.  
  204.     % Display the second 128 encoded characters.
  205.  
  206.   DoTitle (, characters 128-255) show
  207.   128 255 DoBlock
  208.   F 10 scalefont setfont
  209.   36 2.0 Inch moveto 128 191 DoLine
  210.   36 1.5 Inch moveto 192 255 DoLine
  211.   showpage
  212.  
  213.   F /CharStrings known
  214.    {
  215.         % Find and display the unencoded characters.
  216.  
  217.     /Encoded F /Encoding get length dict def
  218.     F /Encoding get { true Encoded 3 1 roll put } forall
  219.     [ F /CharStrings get
  220.      { pop dup Encoded exch known { pop } if }
  221.     forall ] {
  222.       exch Namestring1 cvs exch Namestring2 cvs lt
  223.     } sort DoUnencoded
  224.  
  225.    }
  226.   if
  227.  
  228. } def
  229.  
  230. % print CIDFont sample pages
  231. /DoCIDFont {
  232.   dup /CIDFont findresource InitDoFont
  233.   /DoCode {DoCID} def
  234.   /DoLine {DoCIDLine} def
  235.  
  236.   [ 0 1 F /CIDCount get 1 sub { } for ] DoUnencoded
  237. } def
  238.  
  239. % Do font samples
  240. % /Times-Roman DoFont            % Test (less than a minute)
  241. % /Hershey-Gothic-English DoFont    % Test (8 minutes)
  242.  
  243. % Do a complete catalog
  244. % FontDirectory {pop DoFont} forall    % All fonts (quite a long time)
  245.