home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fonts 1 / freshfonts1.bin / bbs / programs / amiga / pastex13.lha / DVIPS / dvips5519.lha / dvips / tex.lpro < prev    next >
Text File  |  1993-04-25  |  11KB  |  343 lines

  1. % The following defines procedures assumed and used by program "dvips"
  2. % and must be downloaded or sent as a header file for all TeX jobs.
  3. % Originated by Neal Holtz, Carleton University, Ottawa, Canada
  4. %      <holtz@cascade.carleton.cdn>
  5. %      June, 1985
  6. %
  7. %   Hacked by tgr, July 1987, stripped down to bare essentials,
  8. %   plus a few new commands for speed.
  9. %
  10. %   Hacked by don, December 1989, to give characters top down and to
  11. %   remove other small nuisances; merged with tgr's compression scheme
  12. %
  13. % To convert this file into a downloaded file instead of a header
  14. % file, uncomment all of the lines beginning with %-%
  15. %
  16. %   To observe available VM, uncomment the following.
  17. %   (The first ten lines define a general 'printnumber' routine.)
  18. %
  19. % /VirginMtrx 6 array currentmatrix def
  20. % /dummystring 20 string def
  21. % /numberpos 36 def
  22. % /printnumber { gsave VirginMtrx setmatrix
  23. %   /Helvetica findfont 10 scalefont setfont
  24. %   36 numberpos moveto
  25. %   /numberpos numberpos 12 add def
  26. %   dummystring cvs show
  27. %   grestore
  28. %   } bind def
  29. % /showVM { vmstatus exch sub exch pop printnumber } def
  30. % /eop-aux { showVM } def
  31. %
  32. %-%0000000             % Server loop exit password
  33. %-%serverdict begin exitserver
  34. %-%  systemdict /statusdict known
  35. %-%  {statusdict begin 9 0 3 setsccinteractive /waittimeout 300 def end}
  36. %-% if
  37.  
  38. /TeXDict 250 dict def   % define a working dictionary ( IBM: color - 200->250 )
  39. TeXDict begin           % start using it.
  40. /N {def} def
  41. /B {bind def} N
  42. /S {exch} N
  43. /X { S N } B
  44. /TR {translate} N
  45.  
  46. % The output of dvips assumes pixel units, Resolution/inch, with
  47. % increasing y coordinates corresponding to moving DOWNWARD.
  48. % The PostScript default is big point units (bp), 72/inch, with
  49. % increasing y coordinates corresponding to moving UP; the
  50. % following routines handle conversion to dvips conventions. 
  51.  
  52. % Let the PostScript origin be (xps,yps) in dvips coordinates.
  53.  
  54. /isls false N
  55. /vsize 11 72 mul N
  56. /hsize 8.5 72 mul N
  57. /landplus90 { false } def
  58.  
  59. /@rigin                 % -xps -yps @rigin -   establishes dvips conventions
  60.   { isls { [ 0 landplus90 { 1 -1 } { -1 1 } ifelse 0 0 0 ] concat } if
  61.     72 Resolution div 72 VResolution div neg scale
  62.     isls { landplus90 { VResolution 72 div vsize mul 0 exch }
  63.                       { Resolution -72 div hsize mul 0 } ifelse TR } if
  64.     Resolution VResolution vsize -72 div 1 add mul TR
  65. % As bad as setmatrix is, it is better than misalignment.
  66.     matrix currentmatrix
  67.     dup dup 4 get round 4 exch put
  68.     dup dup 5 get round 5 exch put
  69.     setmatrix } N
  70.  
  71. /@landscape { /isls true N } B
  72.  
  73. /@manualfeed
  74.    { statusdict /manualfeed true put
  75.    } B
  76.  
  77.         % n @copies -   set number of copies
  78. /@copies
  79.    { /#copies X
  80.    } B
  81.  
  82. % Bitmap fonts are called Fa, Fb, ..., Fz, F0, F1 . . . Ga . . .
  83. % The calling sequence for downloading font foo is
  84. %           /foo df chardef1 ... chardefn E 
  85. % where each chardef is
  86. %           <hexstring> wd ht xoff yoff dx charno D 
  87. %  or       <hexstring> wd ht xoff yoff dx I
  88. %  or       <hexstring> charno D
  89. %  or       <hexstring> I
  90.  
  91. /FMat [1 0 0 -1 0 0] N
  92. /FBB [0 0 0 0] N
  93.  
  94. /nn 0 N /IE 0 N /ctr 0 N
  95. /df-tail       % id numcc maxcc df-tail -- initialize a new font dictionary
  96.   {
  97. %   dmystr 2 fontname cvx (@@@@) cvs putinterval  % put name in template
  98.     /nn 8 dict N              % allocate new font dictionary
  99.     nn begin
  100.         /FontType 3 N
  101.     /FontMatrix fntrx N
  102.     /FontBBox FBB N
  103.         string /base X
  104.         array /BitMaps X
  105.         /BuildChar {CharBuilder} N
  106.         /Encoding IE N
  107.         end
  108.     dup { /foo setfont }          %  dummy macro to be filled in
  109.        2 array copy cvx N         %  have to allocate a new one
  110.     load                          %  now we change it
  111. %      0 dmystr 6 string copy       %  get a copy of the font name
  112.        0 nn put
  113. %      cvn cvx put                  %  and stick it in the dummy macro
  114.     /ctr 0 N                      %  go, count, and etc.
  115.     [                               %  start next char definition
  116.   } B
  117. /df {
  118.    /sf 1 N
  119.    /fntrx FMat N
  120.    df-tail
  121. } B
  122. /dfs { div /sf X
  123.    /fntrx [ sf 0 0 sf neg 0 0 ] N
  124.    df-tail
  125. } B
  126.  
  127. /E { pop nn dup definefont setfont } B
  128.  
  129. % the following is the only character builder we need.  it looks up the
  130. % char data in the BitMaps array, and paints the character if possible.
  131. % char data  -- a bitmap descriptor -- is an array of length 6, of
  132. %          which the various slots are:
  133.  
  134. /ch-width {ch-data dup length 5 sub get} B % the number of pixels across
  135. /ch-height {ch-data dup length 4 sub get} B % the number of pixels tall
  136. /ch-xoff  {128 ch-data dup length 3 sub get sub} B % num pixels right of origin
  137. /ch-yoff  {ch-data dup length 2 sub get 127 sub} B % number of pixels below origin
  138. /ch-dx  {ch-data dup length 1 sub get} B     % number of pixels to next character
  139. /ch-image {ch-data dup type /stringtype ne
  140.       { ctr get /ctr ctr 1 add N } if
  141.    } B                        % the hex string image, or array of same
  142. %      /id ch-image N                          % image data
  143. /id 0 N /rw 0 N /rc 0 N /gp 0 N /cp 0 N /G 0 N /sf 0 N
  144.  
  145. /CharBuilder    % fontdict ch Charbuilder -     -- image one character
  146.      {save 3 1 roll S dup /base get 2 index get S /BitMaps get S get
  147.       /ch-data X pop
  148.       /ctr 0 N
  149.       ch-dx 0 ch-xoff ch-yoff ch-height sub
  150.       ch-xoff ch-width add ch-yoff
  151.       setcachedevice
  152.       ch-width ch-height true
  153.       [1 0 0 -1 -.1 ch-xoff sub ch-yoff .1 add]
  154. % begin code for uncompressed fonts only
  155.       {ch-image} imagemask
  156.       restore
  157.   } B
  158. % end code for uncompressed fonts only
  159. % % here's the alternate code for unpacking compressed fonts
  160. %      /id ch-image N                          % image data
  161. %      /rw ch-width 7 add 8 idiv string N      % row, initially zero
  162. %      /rc 0 N                                 % repeat count
  163. %      /gp 0 N                                 % image data pointer
  164. %      /cp 0 N                                 % column pointer
  165. %      { rc 0 ne { rc 1 sub /rc X rw } { G } ifelse } imagemask
  166. %    restore
  167. % } B
  168. % /G { { id gp get /gp gp 1 add N
  169. %   dup 18 mod S 18 idiv pl S get exec } loop } B
  170. % /adv { cp add /cp X } B
  171. % /chg { rw cp id gp 4 index getinterval putinterval
  172. %         dup gp add /gp X adv } B
  173. % /nd { /cp 0 N rw exit } B
  174. % /lsh { rw cp 2 copy get dup 0 eq { pop 1 } { dup 255 eq { pop 254 }
  175. %     { dup dup add 255 and S 1 and or } ifelse } ifelse put 1 adv } B
  176. % /rsh { rw cp 2 copy get dup 0 eq { pop 128 } { dup 255 eq { pop 127 }
  177. %     { dup 2 idiv S 128 and or } ifelse } ifelse put 1 adv } B
  178. % /clr { rw cp 2 index string putinterval adv } B
  179. % /set { rw cp fillstr 0 4 index getinterval putinterval adv } B
  180. % /fillstr 18 string 0 1 17 { 2 copy 255 put pop } for N
  181. % /pl [
  182. %    { adv 1 chg }
  183. %    { adv 1 chg nd }
  184. %    { 1 add chg }
  185. %    { 1 add chg nd }
  186. %    { adv lsh }
  187. %    { adv lsh nd }
  188. %    { adv rsh }
  189. %    { adv rsh nd }
  190. %    { 1 add adv }
  191. %    { /rc X nd }
  192. %    { 1 add set }
  193. %    { 1 add clr }
  194. %    { adv 2 chg }
  195. %    { adv 2 chg nd }
  196. %    { pop nd } ] dup { bind pop } forall N
  197. % % end of code for unpacking compressed fonts
  198.  
  199.                % in the following, the font-cacheing mechanism requires that
  200.                 % a name unique in the particular font be generated
  201.  
  202. /D            % char-data ch D -    -- define character bitmap in current font
  203.   { /cc X
  204.     dup type /stringtype ne {]} if
  205.     nn /base get cc ctr put
  206.     nn /BitMaps get S ctr S
  207.     sf 1 ne {
  208.        dup dup length 1 sub dup 2 index S get sf div put
  209.     } if
  210.     put
  211.     /ctr ctr 1 add N
  212.   } B
  213.  
  214. /I            % a faster D for when the next char follows immediately
  215.   { cc 1 add D } B
  216.  
  217. /bop           % %t %d bop -  -- begin a brand new page, %t=pageno %d=seqno
  218.   {
  219.     userdict /bop-hook known { bop-hook } if
  220.     /SI save N
  221.     @rigin
  222. %
  223. %   Now we check the resolution.  If it's correct, we use RV as V,
  224. %   otherwise we use QV.
  225. %
  226.     0 0 moveto
  227.     /V matrix currentmatrix
  228.     dup 1 get dup mul exch 0 get dup mul add .99 lt
  229.     {/QV} {/RV} ifelse load def
  230.     pop pop
  231.   } N
  232.  
  233. /eop           % - eop -              -- end a page
  234.   { % eop-aux  % -- to observe VM usage
  235.     SI restore
  236.     showpage
  237.     userdict /eop-hook known { eop-hook } if
  238.   } N
  239.  
  240. /@start         % hsz vsz mag dpi vdpi name @start -   -- star