home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume20 / psroff / part04 / genftable.ps next >
Text File  |  1989-10-17  |  14KB  |  579 lines

  1. %!
  2. % genftable - Postcript program to produce font tables for ditroff.
  3. %          Tables are output on the standard output file - which
  4. %          needs to be captured by the host computer.
  5. %
  6. %          Note the routine "commondefs" which outputs local
  7. %          defined (hand built) characters.
  8. %
  9. % Michael Rourke, University of N.S.W., Australia
  10. % (included in troff2: 1.2 89/08/25)
  11.  
  12. /t 30 string def
  13.  
  14. (Starting genftable.ps\n) print
  15.  
  16. /ps
  17. % string ->
  18. {
  19.     print
  20. } def
  21.  
  22. /pr
  23. % any -->
  24. {
  25.     t cvs ps
  26. } def
  27.  
  28. /prsp
  29. {
  30.     (\t) ps
  31. } def
  32.  
  33. /prnl
  34. {
  35.     (\n) ps
  36. } def
  37.  
  38. /pro
  39. % int -->
  40. {
  41.     dup 0 eq
  42.     { pr }
  43.     { dup 8 idiv pro 8 mod pr }
  44.     ifelse
  45. } def
  46.  
  47. /charsize
  48. % string --> bot top
  49. {
  50.     gsave
  51.     newpath 0 0 moveto false charpath flattenpath pathbbox
  52.     exch pop 3 -1 roll pop
  53.     grestore
  54. } def
  55.  
  56. /strwidth
  57. % string --> width
  58. {
  59.     stringwidth pop round cvi
  60. } def
  61.  
  62. /prsize
  63. % string -->
  64. {
  65.     dup strwidth pr prsp
  66.     dup charsize
  67.     top gt { 2 } { 0 } ifelse
  68.     exch bot lt { 1 or } if
  69.     pr prsp
  70.     0 get pro 
  71. } def
  72.  
  73. /fontinfo
  74. % fontname troffinternal troffname
  75. {
  76.     (\ncat <<"!" > ) ps dup pr prnl
  77.     (# ) ps 2 index pr prnl
  78.     (name ) ps pr prnl
  79.     (internalname ) ps pr prnl
  80.     dup findfont 100 scalefont setfont
  81.     /fixedwidth false def
  82.     /Symbol eq
  83.     {
  84.         /actions symbol-encoding def
  85.         (special\n) ps
  86.     }
  87.     {
  88.         /actions standard-encoding def
  89.         currentfont /FontInfo get /isFixedPitch get
  90.         {
  91.             (# fixed width\n) ps
  92.             /fixedwidth true def
  93.         }
  94.         {
  95.             (ligatures fi fl ff ffi ffl 0\n) ps
  96.         }
  97.         ifelse
  98.     }
  99.     ifelse
  100.     % use "o" to get top and bottom on a normal char
  101.     (o) charsize /top exch def /bot exch def
  102.     % some non ascending chars slightly higher than "o"
  103.     % and some lower so adjust slightly
  104.     /top top 2 add def
  105.     /bot bot 4 sub def
  106.     /encoding currentfont /Encoding get def
  107.     /s 1 string def
  108.     0 1 255
  109.     {
  110.         s 0 2 index put
  111.         encoding exch get dup /.notdef ne
  112.         {
  113.             s 1 index actions exch get
  114.             % charname charstr
  115.             exec
  116.             flush
  117.         }
  118.         {
  119.             pop
  120.         }        
  121.         ifelse
  122.     } for
  123.     actions standard-encoding eq { commondefs } if
  124.     (!\n) ps flush
  125. } def
  126.  
  127. /commondefs
  128. {
  129.     /fracsize (0) strwidth (\244) strwidth add def        % \244 = '/'
  130.     /Fisize (f) strwidth (\256) strwidth add 5 sub def    % \256 = 'fi'
  131.     /ffsize (f) strwidth 2 mul 5 sub def
  132.     /fl { flush } def
  133.     fixedwidth not
  134.     {
  135.         (ff) ps prsp ffsize pr (\t2\t0100\tff ligature - faked\n) ps fl
  136.         (Fi) ps prsp Fisize pr (\t2\t0100\tffi ligature - faked\n) ps fl
  137.         (Fl) ps prsp Fisize pr (\t2\t0100\tffl ligature - faked\n) ps fl
  138.     } if
  139.     (12) ps prsp fracsize pr (\t2\t0100\t1/2 - faked\n) ps fl
  140.     (13) ps prsp fracsize pr (\t2\t0100\t1/3 - faked\n) ps fl
  141.     (14) ps prsp fracsize pr (\t2\t0100\t1/4 - faked\n) ps fl
  142.     (18) ps prsp fracsize pr (\t2\t0100\t1/8 - faked\n) ps fl
  143.     (23) ps prsp fracsize pr (\t2\t0100\t2/3 - faked\n) ps fl
  144.     (34) ps prsp fracsize pr (\t2\t0100\t3/4 - faked\n) ps fl
  145.     (38) ps prsp fracsize pr (\t2\t0100\t3/8 - faked\n) ps fl
  146.     (58) ps prsp fracsize pr (\t2\t0100\t5/8 - faked\n) ps fl
  147.     (78) ps prsp fracsize pr (\t2\t0100\t7/8 - faked\n) ps fl
  148.     (sq\t100\t3\t0100\tsquare box - faked\n) ps fl
  149. } def
  150.  
  151. /space
  152. % charname charstr -->
  153. {
  154.     (spacewidth ) ps
  155.     strwidth pr pop prnl
  156.     (charset\n) ps
  157. } def
  158.  
  159. /norm
  160. % charname charstr -->
  161. {
  162.     dup pr prsp prsize pop prnl
  163. } def
  164.  
  165. /normdup
  166. % charname charstr dupname -->
  167. {
  168.     3 1 roll norm
  169.     pr prsp (") ps prnl
  170. } def
  171.  
  172. /gnorm
  173. % charname charstr -->
  174. {
  175.     (*) ps norm
  176. } def
  177.  
  178. /map
  179. % charname charstr mapname -->
  180. {
  181.     pr prsp prsize prsp pr prnl
  182. } def
  183.  
  184. /mapdup
  185. % charname charstr mapname dupname -->
  186. {
  187.     4 1 roll map
  188.     pr prsp (") ps prnl
  189. } def
  190.  
  191. /mapdupdup
  192. % charname charstr mapname dupname dupname -->
  193. {
  194.     5 1 roll mapdup
  195.     pr prsp (") ps prnl
  196. } def
  197.  
  198. /cmap
  199. % charname charstr mapname -->
  200. {
  201.     fixedwidth { 3 { pop } repeat } { map } ifelse
  202. } def
  203.  
  204. /standard-encoding 149 dict def
  205. standard-encoding begin
  206.     /space        { space }        def
  207.     /exclam        { norm }        def
  208.     /quotedbl    { norm }        def
  209.     /numbersign    { norm }        def
  210.     /dollar        { norm }        def
  211.     /percent    { norm }        def
  212.     /ampersand    { norm }        def
  213.     /quoteright    { norm }        def
  214.     /parenleft    { norm }        def
  215.     /parenright    { norm }        def
  216.     /asterisk    { norm }        def
  217.     /plus        { norm }        def
  218.     /comma        { norm }        def
  219.     /hyphen        { (hy) normdup }    def
  220.     /period        { norm }        def
  221.     /slash        { (sl) dup }        def
  222.     /zero        { norm }        def
  223.     /one        { norm }        def
  224.     /two        { norm }        def
  225.     /three        { norm }        def
  226.     /four        { norm }        def
  227.     /five        { norm }        def
  228.     /six        { norm }        def
  229.     /seven        { norm }        def
  230.     /eight        { norm }        def
  231.     /nine        { norm }        def
  232.     /colon        { norm }        def
  233.     /semicolon    { norm }        def
  234.     /less        { norm }        def
  235.     /equal        { norm }        def
  236.     /greater    { norm }        def
  237.     /question    { norm }        def
  238.     /at        { norm }        def
  239.     /A        { norm }        def
  240.     /B        { norm }        def
  241.     /C        { norm }        def
  242.     /D        { norm }        def
  243.     /E        { norm }        def
  244.     /F        { norm }        def
  245.     /G        { norm }        def
  246.     /H        { norm }        def
  247.     /I        { norm }        def
  248.     /J        { norm }        def
  249.     /K        { norm }        def
  250.     /L        { norm }        def
  251.     /M        { norm }        def
  252.     /N        { norm }        def
  253.     /O        { norm }        def
  254.     /P        { norm }        def
  255.     /Q        { norm }        def
  256.     /R        { norm }        def
  257.     /S        { norm }        def
  258.     /T        { norm }        def
  259.     /U        { norm }        def
  260.     /V        { norm }        def
  261.     /W        { norm }        def
  262.     /X        { norm }        def
  263.     /Y        { norm }        def
  264.     /Z        { norm }        def
  265.     /bracketleft    { norm }        def
  266.     /backslash    { norm }        def
  267.     /bracketright    { norm }        def
  268.     /asciicircum    { (a^) map }        def
  269.     /underscore    { (ru) normdup }    def
  270.     /quoteleft    { norm }        def
  271.     /a        { norm }        def
  272.     /b        { norm }        def
  273.     /c        { norm }        def
  274.     /d        { norm }        def
  275.     /e        { norm }        def
  276.     /f        { norm }        def
  277.     /g        { norm }        def
  278.     /h        { norm }        def
  279.     /i        { norm }        def
  280.     /j        { norm }        def
  281.     /k        { norm }        def
  282.     /l        { norm }        def
  283.     /m        { norm }        def
  284.     /n        { norm }        def
  285.     /o        { norm }        def
  286.     /p        { norm }        def
  287.     /q        { norm }        def
  288.     /r        { norm }        def
  289.     /s        { norm }        def
  290.     /t        { norm }        def
  291.     /u        { norm }        def
  292.     /v        { norm }        def
  293.     /w        { norm }        def
  294.     /x        { norm }        def
  295.     /y        { norm }        def
  296.     /z        { norm }        def
  297.     /braceleft    { norm }        def
  298.     /bar        { norm }        def
  299.     /braceright    { norm }        def
  300.     /asciitilde    { (a~) map }        def
  301.     /exclamdown    { (I!) map }        def
  302.     /cent        { (ct) map }        def
  303.     /sterling    { (po) map }        def
  304.     /fraction    { }            def
  305.     /yen        { ($J) map }        def
  306.     /florin        { }            def
  307.     /section    { (sc) map }        def
  308.     /currency    { }            def
  309.     /quotesingle    { (fm) (n') mapdup }    def
  310.     /quotedblleft    { (lq) map }        def
  311.     /guillemotleft    { (d<) map }        def
  312.     /guilsinglleft    { (l<) map }        def
  313.     /guilsinglright    { (r>) map }        def
  314.     /fi        { (fi) cmap }        def
  315.     /fl        { (fl) cmap }        def
  316.     /endash        { (\\-) map }        def
  317.     /dagger        { (dg) map }        def
  318.     /daggerdbl    { (dd) map }        def
  319.     /periodcentered    { }            def
  320.     /paragraph    { (pp) map }        def
  321.     /bullet        { (bu) map }        def
  322.     /quotesinglbase    { }             def
  323.     /quotedblbase    { }            def
  324.     /quotedblright    { (rq) map }        def
  325.     /guillemotright    { (d>) map }        def
  326.     /ellipsis    { }            def
  327.     /perthousand    { (pm) cmap }        def
  328.     /questiondown    { (I?) map }        def
  329.     /grave        { (ga) (\\`) mapdup }    def
  330.     /acute        { (aa) (\\') mapdup }    def
  331.     /circumflex    { (^) map }        def
  332.     /tilde        { (~) map }        def
  333.     /macron        { (ma) map }        def
  334.     /breve        { (be) map }        def
  335.     /dotaccent    { (dt) map }        def
  336.     /dieresis    { (..) (um) mapdup }    def
  337.     /ring        { (ri) map }        def
  338.     /cedilla    { (cd) map }        def
  339.     /hungarumlaut    { ('') map }        def
  340.     /ogonek        { (og) map }        def
  341.     /caron        { (hc) map }        def
  342.     /emdash        { (em) map }        def
  343.     /AE        { (AE) cmap }        def
  344.     /ordfeminine    { }            def
  345.     /Lslash        { (PL) map }        def
  346.     /Oslash        { (O/) map }        def
  347.     /OE        { (OE) cmap }        def
  348.     /ordmasculine    { }            def
  349.     /ae        { (ae) cmap }        def
  350.     /dotlessi    { (ui) map }        def
  351.     /lslash        { (Pl) map }        def
  352.     /oslash        { (o/) map }        def
  353.     /oe        { (oe) cmap }        def
  354.     /germandbls    { (ss) map }        def
  355. end
  356.  
  357. /symbol-encoding 189 dict def
  358. symbol-encoding begin
  359.     /space        { space }        def
  360.     /exclam        { norm }        def
  361.     /universal    { (fa) map }        def
  362.     /numbersign    { norm }        def
  363.     /existential    { (te) map }        def
  364.     /percent    { norm }        def
  365.     /ampersand    { norm }        def
  366.     /suchthat    { (cm) map }        def
  367.     /parenleft    { norm }        def
  368.     /parenright    { norm }        def
  369.     /asteriskmath    { (**) map }        def
  370.     /plus        { (pl) map }        def
  371.     /comma        { norm }        def
  372.     /minus        { (mi) normdup }    def
  373.     /period        { norm }        def
  374.     /slash        { (sl) map }        def
  375.     /zero        { norm }        def
  376.     /one        { norm }        def
  377.     /two        { norm }        def
  378.     /three        { norm }        def
  379.     /four        { norm }        def
  380.     /five        { norm }        def
  381.     /six        { norm }        def
  382.     /seven        { norm }        def
  383.     /eight        { norm }        def
  384.     /nine        { norm }        def
  385.     /colon        { norm }        def
  386.     /semicolon    { norm }        def
  387.     /less        { norm }        def
  388.     /equal        { (eq) normdup }    def
  389.     /greater    { norm }        def
  390.     /question    { norm }        def
  391.     /congruent    { (=~) map }        def
  392.     /Alpha        { gnorm }        def
  393.     /Beta        { gnorm }        def
  394.     /Chi        { (*X) map }        def
  395.     /Delta        { gnorm }        def
  396.     /Epsilon    { gnorm }        def
  397.     /Phi        { gnorm }        def
  398.     /Gamma        { gnorm }        def
  399.     /Eta        { (*Y) map }        def
  400.     /Iota        { gnorm }        def
  401.     /theta1        { }            def
  402.     /Kappa        { gnorm }        def
  403.     /Lambda        { gnorm }        def
  404.     /Mu        { gnorm }        def
  405.     /Nu        { gnorm }        def
  406.     /Omicron    { gnorm }        def
  407.     /Pi        { gnorm }        def
  408.     /Theta        { (*H) map }        def
  409.     /Rho        { gnorm }        def
  410.     /Sigma        { gnorm }        def
  411.     /Tau        { gnorm }        def
  412.     /Upsilon    { gnorm }        def
  413.     /sigma1        { (ts) map }        def
  414.     /Omega        { (*W) map }        def
  415.     /Xi        { (*C) map }        def
  416.     /Psi        { (*Q) map }        def
  417.     /Zeta        { gnorm }        def
  418.     /bracketleft    { norm }        def
  419.     /therefore    { (tf) map }        def
  420.     /bracketright    { norm }        def
  421.     /perpendicular    { (bt) map }        def
  422.     /underscore    { (ul) map }        def
  423.     /radicalex    { }            def
  424.     /alpha        { gnorm }        def
  425.     /beta        { gnorm }        def
  426.     /chi        { (*x) map }        def
  427.     /delta        { gnorm }        def
  428.     /epsilon    { gnorm }        def
  429.     /phi        { gnorm }        def
  430.     /gamma        { gnorm }        def
  431.     /eta        { (*y) map }        def
  432.     /iota        { gnorm }        def
  433.     /phi1        { }            def
  434.     /kappa        { gnorm }        def
  435.     /lambda        { gnorm }        def
  436.     /mu        { gnorm }        def
  437.     /nu        { gnorm }        def
  438.     /omicron    { gnorm }        def
  439.     /pi        { gnorm }        def
  440.     /theta        { (*h) map }        def
  441.     /rho        { gnorm }        def
  442.     /sigma        { gnorm }        def
  443.     /tau        { gnorm }        def
  444.     /upsilon    { gnorm }        def
  445.     /omega1        { }            def
  446.     /omega        { (*w) map }        def
  447.     /xi        { (*c) map }        def
  448.     /psi        { (*q) map }        def
  449.     /zeta        { gnorm }        def
  450.     /braceleft    { norm }        def
  451.     /bar        { (or) normdup }    def
  452.     /braceright    { norm }        def
  453.     /similar    { (ap) map }        def
  454.     /Upsilon1    { }            def
  455.     /minute        { (mt) map }        def
  456.     /lessequal    { (<=) map }        def
  457.     /fraction    { (/) map }        def
  458.     /infinity    { (if) map }        def
  459.     /florin        { }            def
  460.     /club        { (Cc) map }        def
  461.     /diamond    { (Cd) map }        def
  462.     /heart        { (Ch) map }        def
  463.     /spade        { (Cs) map }        def
  464.     /arrowboth    { (<>) map }        def
  465.     /arrowleft    { (<-) map }        def
  466.     /arrowup    { (ua) map }        def
  467.     /arrowright    { (->) map }        def
  468.     /arrowdown    { (da) map }        def
  469.     /degree        { (de) map }        def
  470.     /plusminus    { (+-) map }        def
  471.     /second        { (sd) map }        def
  472.     /greaterequal    { (>=) map }        def
  473.     /multiply    { (mu) map }        def
  474.     /proportional    { (pt) map }        def
  475.     /partialdiff    { (pd) map }        def
  476.     /bullet        { }            def
  477.     /divide        { (di) map }        def
  478.     /notequal    { (!=) map }        def
  479.     /equivalence    { (==) map }        def
  480.     /approxequal    { (~=) map }        def
  481.     /ellipsis    { }            def
  482.     /arrowvertex    { }            def
  483.     /arrowhorizex    { }            def
  484.     /carriagereturn    { (cr) map }        def
  485.     /aleph        { (al) map }        def
  486.     /Ifraktur    { }            def
  487.     /Rfraktur    { }            def
  488.     /weierstrass    { }            def
  489.     /circlemultiply    { (ax) map }        def
  490.     /circleplus    { (a+) map }        def
  491.     /emptyset    { (es) map }        def
  492.     /intersection    { (ca) map }        def
  493.     /union        { (cu) map }        def
  494.     /propersuperset    { (sp) map }        def
  495.     /reflexsuperset    { (ip) map }        def
  496.     /notsubset    { (!s) map }        def
  497.     /propersubset    { (sb) map }        def
  498.     /reflexsubset    { (ib) map }        def
  499.     /element    { (mo) map }        def
  500.     /notelement    { (!m) (nm) mapdup }    def
  501.     /angle        { (ag) map }        def
  502.     /gradient    { (gr) map }        def
  503.     /registerserif    { }            def
  504.     /copyrightserif    { }            def
  505.     /trademarkserif    { }            def
  506.     /product    { }            def
  507.     /radical    { (sr) map }        def
  508.     /dotmath    { (m.) map }        def
  509.     /logicalnot    { (no) map }        def
  510.     /logicaland    { (an) (la) mapdup }    def
  511.     /logicalor    { (lo) map }        def
  512.     /arrowdblboth    { (io) map }        def
  513.     /arrowdblleft    { (<:) (lh) mapdup }    def
  514.     /arrowdblup    { (u=) map }        def
  515.     /arrowdblright    { (:>) (rh) (im) mapdupdup } def
  516.     /arrowdbldown    { (d=) map }        def
  517.     /lozenge    { (dm) map }        def
  518.     /angleleft    { (L<) map }        def
  519.     /registersans    { (rg) map }        def
  520.     /copyrightsans    { (co) map }        def
  521.     /trademarksans    { (tm) map }        def
  522.     /summation    { }            def
  523.     /parenlefttp    { }            def
  524.     /parenleftex    { }            def
  525.     /parenleftbt    { }            def
  526.     /bracketlefttp    { }            def
  527.     /bracketleftex    { }            def
  528.     /bracketleftbt    { }            def
  529.     /bracelefttp    { }            def
  530.     /braceleftmid    { }            def
  531.     /braceleftbt    { }            def
  532.     /braceex    { }            def
  533.     /apple        { (AL) map }        def
  534.     /angleright    { (R>) map }        def
  535.     /integral    { (is) map }        def
  536.     /integraltp    { }            def
  537.     /integralex    { }            def
  538.     /integralbt    { }            def
  539.     /parenrighttp    { }            def
  540.     /parenrightex    { }            def
  541.     /parenrightbt    { }            def
  542.     /bracketrighttp    { }            def
  543.     /bracketrightex    { }            def
  544.     /bracketrightbt    { }            def
  545.     /bracerighttp    { }            def
  546.     /bracerightmid    { }            def
  547.     /bracerightbt    { }            def
  548. end
  549.  
  550. /Times-Roman        /Roman        /R    fontinfo
  551. /Helvetica        /Helvetica    /H    fontinfo
  552. /Courier        /Courier    /C    fontinfo
  553. /Symbol            /Symbol        /S    fontinfo
  554. /Times-Italic        /Italic        /I    fontinfo
  555. /Times-Bold        /Bold        /B    fontinfo
  556. /Times-BoldItalic    /BoldI        /BI    fontinfo
  557. /Helvetica-Bold        /HelveticaB    /HB    fontinfo
  558. /Helvetica-Oblique    /HelveticaO    /HO    fontinfo
  559. /Helvetica-BoldOblique    /HelveticaBO    /HX    fontinfo
  560. /Courier-Bold        /CourierB    /CB    fontinfo
  561. /Courier-Oblique    /CourierO    /CO    fontinfo
  562. /Courier-BoldOblique    /CourierBO    /CX    fontinfo
  563. /Helvetica-Narrow    /HelvNarHn    /Hn    fontinfo
  564. /Helvetica-Narrow-Oblique /HelvNarHo    /Ho    fontinfo
  565. /Helvetica-Narrow-BoldOblique    /HelvNarHx    /Hx    fontinfo
  566. /ZapfChancery-MediumItalic    /ZapfC    /ZC    fontinfo
  567. /AvantGarde-Book    /AvantAR    /AR    fontinfo
  568. /AvantGarde-BookOblique    /AvantAX    /AX    fontinfo
  569. /AvantGarde-Demi    /AvantAB    /AB    fontinfo
  570. /AvantGarde-DemiItalic    /AvantAI    /AI    fontinfo
  571. /Palatino-Roman    /PalatPR    /PR    fontinfo
  572. /Palatino-Bold    /PalatPB    /PB    fontinfo
  573. /Palatino-BoldItalic /PalatPX    /PX    fontinfo
  574. /Palatino-Italic /PalatPI    /PI    fontinfo
  575. /NewCenturySchlbk-Bold        /NB    fontinfo
  576. /NewCenturySchlbk-BoldItalic    /NX    fontinfo
  577. /NewCenturySchlbk-Italic    /NI    fontinfo
  578. /NewCenturySchlbk-Roman        /NR    fontinfo
  579.