home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / PRINTING / DVIPS54.ZIP / DVIPS / SPECIAL.LPR < prev    next >
Text File  |  1990-11-25  |  8KB  |  315 lines

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