home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / unixtex-6.1b-src.tgz / tar.out / contrib / unixtex / xdvik / psheader.txt < prev    next >
Text File  |  1996-09-28  |  9KB  |  357 lines

  1. %% These are from tex.lpro
  2. /TeXDict 250 dict def   % define a working dictionary ( IBM: color - 200->250 )
  3. TeXDict begin           % start using it.
  4. /N {def} def
  5. /B {bind def} N
  6. /S {exch} N
  7. /X { S N } B
  8. /TR {translate} N
  9. end % TeXDict
  10.  
  11. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12. %%     header for the \special command
  13. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  14. %   The structure of the PostScript produced by dvips for \special is:
  15. %         @beginspecial
  16. %           - any number of @hsize, @hoffset, @hscale, etc., commands
  17. %         @setspecial
  18. %           - the user's file of PostScript commands
  19. %         @endspecial
  20.  
  21. TeXDict begin
  22. /SDict 200 dict N
  23. SDict begin
  24.  
  25. /@SpecialDefaults
  26.   { /hs 612 N
  27.     /vs 792 N
  28.     /ho 0 N
  29.     /vo 0 N
  30.     /hsc 1 N
  31.     /vsc 1 N
  32.     /ang 0 N
  33.     /CLIP 0 N
  34.     /rwiSeen false N
  35.     /rhiSeen false N
  36.     /letter {} N /note {} N /a4 {} N /legal {} N
  37.   } B
  38.  
  39. %
  40. %   The following definition sets up the units that hscale/vscale are in.
  41. %   For certain sites this might require change, but it is
  42. %   recommended instead that any macro packages that require
  43. %   hscale/vscale set the units appropriately via
  44. %
  45. %   \special{! /@scaleunit 1 def }
  46. %
  47. %   if global, or
  48. %
  49. %   \special{" /@scaleunit 1 def }
  50. %
  51. %   before each instance if multiple macro packages with
  52. %   different requirements are being used.
  53. %
  54. /@scaleunit 100 N
  55. %       s @hscale  -    set scale factor
  56. /@hscale {@scaleunit div /hsc X} B
  57. /@vscale {@scaleunit div /vsc X} B
  58.  
  59. %       d @hsize   -    specify a horizontal clipping dimension
  60. /@hsize {/hs X /CLIP 1 N} B
  61. /@vsize {/vs X /CLIP 1 N} B
  62.  
  63. /@clip {/CLIP 2 N} B
  64.  
  65. %       d @hoffset -    specify a shift for the figure
  66. /@hoffset {/ho X} B
  67. /@voffset {/vo X} B
  68.  
  69. %       a @angle   -    set rotation angle
  70. /@angle {/ang X} B
  71.  
  72. %
  73. %   Here we handle bounding box calculations, if necessary.
  74. %
  75. /@rwi { 10 div /rwi X /rwiSeen true N } B % rwi will be real width after scaling
  76. /@rhi { 10 div /rhi X /rhiSeen true N } B % rhi will be real height after scaling
  77. /@llx { /llx X } B
  78. /@lly { /lly X } B
  79. /@urx { /urx X } B
  80. /@ury { /ury X } B
  81.  
  82. /magscale true def
  83.  
  84. end % of SDict
  85.  
  86. /@MacSetUp
  87.   { userdict /md known  % if md is defined
  88.       { userdict /md get type /dicttype eq      % and if it is a dictionary
  89.     {
  90.         userdict begin                       % expand it if necessary
  91.            md length 10 add md maxlength ge
  92.            {/md md dup length 20 add dict copy def}if
  93.         end
  94.     md begin                             % then redefine some stuff
  95.     /letter {} N
  96.     /note {} N
  97.     /legal {} N
  98.     /od{txpose
  99.         1 0 mtx defaultmatrix dtransform S atan/pa X
  100.         newpath clippath mark
  101.         {transform{itransform moveto}}
  102.         {transform{itransform lineto}}
  103.         { 6 -2 roll transform
  104.           6 -2 roll transform
  105.           6 -2 roll transform
  106.           { itransform 6 2 roll
  107.         itransform 6 2 roll
  108.         itransform 6 2 roll
  109.         curveto
  110.           }
  111.         }
  112.         {{closepath}}
  113.         pathforall newpath counttomark array astore /gc xdf
  114.         pop ct 39 0 put
  115.         10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if
  116.     }N
  117.     /txpose{
  118.         pxs pys scale ppr aload pop
  119.         por {
  120.         noflips {
  121.             pop S neg S TR pop 1 -1 scale
  122.         }if
  123.         xflip yflip and {
  124.             pop S neg S TR 180 rotate 1 -1 scale
  125.             ppr 3 get ppr 1 get neg sub neg ppr 2 get
  126.             ppr 0 get neg sub neg TR
  127.         }if
  128.         xflip yflip not and {
  129.             pop S neg S TR pop 180 rotate
  130.             ppr 3 get ppr 1 get neg sub neg 0 TR
  131.         }if
  132.         yflip xflip not and {
  133.             ppr 1 get neg ppr 0 get neg TR
  134.         }if
  135.         }
  136.         {
  137.         noflips {
  138.             TR pop pop 270 rotate 1 -1 scale
  139.         }if
  140.         xflip yflip and {
  141.             TR pop pop 90 rotate 1 -1 scale
  142.             ppr 3 get ppr 1 get neg sub neg ppr 2 get
  143.             ppr 0 get neg sub neg TR
  144.         }if
  145.         xflip yflip not and {
  146.             TR pop pop 90 rotate ppr 3 get
  147.             ppr 1 get neg sub neg 0 TR
  148.         }if
  149.         yflip xflip not and {
  150.             TR pop pop 270 rotate ppr 2 get
  151.             ppr 0 get neg sub neg 0 S TR
  152.         }if
  153.         }ifelse
  154.         scaleby96 {
  155.         ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy
  156.         TR .96 dup scale neg S neg S TR
  157.         }if
  158.     }N
  159.     /cp {pop pop showpage pm restore}N
  160.         end
  161.       }if
  162.     } if
  163.   } N
  164.  
  165. %
  166. %   The following procedure brings us back to PostScript size.  It takes
  167. %   into account the current global dvi magnification, so graphics
  168. %   scale with the document.
  169. %
  170. /normalscale {
  171.     Resolution 72 div VResolution 72 div neg scale
  172.     magscale { DVImag dup scale } if
  173.     0 setgray
  174. } N
  175. %
  176. %   We need the psfig macros.
  177. %
  178. % All software, documentation, and related files in this distribution of
  179. % psfig/tex are Copyright (c) 1987 Trevor J. Darrell
  180. %
  181. % Permission is granted for use and non-profit distribution of psfig/tex
  182. % providing that this notice be clearly maintained, but the right to
  183. % distribute any portion of psfig/tex for profit or as part of any commercial
  184. % product is specifically reserved for the author.
  185. %
  186. %
  187. % psfigTeX PostScript Prolog
  188. % $Header: /usr/local/src/TeX/Dvips-5.0.2/RCS/special.lpro,v 1.1 90/03/10 20:32:57 grunwald Exp $
  189. %
  190. /psfts { S 65781.76 div N } N
  191.  
  192. %  x y bb-llx bb-lly bb-urx bb-ury startTexFig -
  193. /startTexFig {
  194.     /psf$SavedState save N
  195.     userdict maxlength dict begin
  196.  
  197.     /magscale false def
  198.     normalscale
  199.         currentpoint TR    %set the current point as the user's origin
  200.  
  201.     /psf$ury psfts
  202.     /psf$urx psfts
  203.     /psf$lly psfts
  204.     /psf$llx psfts
  205.     /psf$y psfts
  206.     /psf$x psfts
  207.  
  208.     /psf$sx psf$x psf$urx psf$llx sub div N    % scaling for x
  209.     /psf$sy psf$y psf$ury psf$lly sub div N    % scaling for y
  210.  
  211.     psf$sx psf$sy scale            % scale by (sx,sy)
  212.  
  213.     psf$llx neg psf$ury neg TR
  214.  
  215.     /showpage {
  216.     } N
  217.     /erasepage {
  218.     } N
  219.     /copypage {
  220.     } N
  221.         /p 3 def % necessary to get around a bug in Adobe Illustrator
  222.     @MacSetUp
  223. } N
  224.  
  225. % llx lly urx ury doclip -    (args in figure coordinates)
  226. /doclip {
  227.         psf$llx psf$lly psf$urx psf$ury
  228.     currentpoint 6 2 roll
  229.     newpath 4 copy
  230.     4 2 roll moveto
  231.     6 -1 roll S lineto
  232.     S lineto
  233.     S lineto
  234.     closepath clip
  235.     newpath
  236.     moveto
  237. } N
  238. % - endTexFig -
  239. /endTexFig { end psf$SavedState restore } N
  240.  
  241. % this will be invoked as the result of a \special command (for the
  242. % inclusion of PostScript graphics).  The basic idea is to change all
  243. % scaling and graphics back to defaults, but to shift the origin
  244. % to the current position on the page.
  245.  
  246. /@beginspecial          % - @beginspecial -     -- enter special mode
  247.   { 
  248.     /SpecialSave save N
  249.     SDict begin
  250.     gsave
  251.     normalscale
  252.     currentpoint TR    %set the current point as the user's origin
  253.     @SpecialDefaults    % setup default offsets, scales, sizes, and angle
  254.     count /ocount X /dcount countdictstack N
  255.   } N
  256.  
  257. /@setspecial    % to setup user specified offsets, scales, sizes (for clipping)
  258.   {
  259.     CLIP 1 eq
  260.       { newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto
  261.         closepath clip }
  262.     if
  263.     ho vo TR
  264.     hsc vsc scale
  265.     ang rotate
  266.     rwiSeen {
  267.        rwi urx llx sub div
  268.        rhiSeen { rhi ury lly sub div } { dup } ifelse
  269.        scale llx neg lly neg TR
  270.     } {
  271.        rhiSeen { rhi ury lly sub div dup scale llx neg lly neg TR } if
  272.     } ifelse
  273.     CLIP 2 eq
  274.     { newpath llx lly moveto urx lly lineto urx ury lineto llx ury lineto
  275.       closepath clip }
  276.     if
  277.     /showpage {} N
  278.     /erasepage {} N
  279.     /copypage {} N
  280.     newpath
  281.   } N
  282.  
  283. /@endspecial            % - @endspecial -       -- leave special mode
  284.   { count ocount sub {pop} repeat
  285.     countdictstack dcount sub {end} repeat
  286.     grestore SpecialSave restore
  287.     end
  288.   } N
  289.  
  290. % xdvik special treatment for saving definitions made in SDict (while using
  291. % the bang special; try to guarantee that the dictionary stack is ok!
  292. %   xdvik should not systematically bracket code within save/restore pairs,
  293. % anyway: such bracketing breaks a lot of code (many packages do change
  294. % TeXDict from with ps: specials for instance) and we should only guarantee
  295. % that bracketing is done within @beginspecial and @endspecial.  -- YA
  296.  
  297. /@xdvisavestate
  298.   {
  299.     userdict /xdvi$sav save put
  300.   } N
  301.  
  302. /@defspecial
  303.   {
  304.     SDict begin
  305.   } N
  306.  
  307. /@fedspecial
  308.   {
  309.     end
  310.     @xdvisavestate
  311.   } B
  312.  
  313. %%% macros for tpic
  314. /li             % x y li -              -- draw line to
  315.   { lineto
  316.   } B
  317.  
  318. /rl             % dx dy rl -            -- draw relative line
  319.   { rlineto
  320.   } B
  321.  
  322. /rc             % x0 y0 x1 y1 y2 y2 rc  -- draw bezier curve
  323.   { rcurveto
  324.   } B
  325.  
  326. /np        % np -            -- start a new path and save currentpoint
  327.   { /SaveX currentpoint /SaveY X N   % remember current point
  328.     1 setlinecap
  329.     newpath
  330.   } N
  331.  
  332. /st             % st -                  -- draw the last path and restore currentpoint
  333.   { stroke
  334.     SaveX SaveY moveto                  % restore the current point
  335.   } N
  336.  
  337. /fil             % fil                    -- fill the last path and restore currentpoint
  338.   { fill
  339.     SaveX SaveY moveto                  % restore the current point
  340.   } N
  341.  
  342. /ellipse        % xc yc xrad yrad startAngle endAngle ellipse
  343.     {
  344.         /endangle X
  345.         /startangle X
  346.         /yrad X
  347.         /xrad X
  348.  
  349.         /savematrix matrix currentmatrix N
  350.  
  351.         TR xrad yrad scale
  352.         0 0 1 startangle endangle arc
  353.         savematrix setmatrix
  354.     } N
  355. %%% end of macros for tpic
  356. end                     % revert to previous dictionary
  357.