home *** CD-ROM | disk | FTP | other *** search
/ Computer Buyer 1996 April / BYER_0496.iso / buisapp / design / dwk3 / libs / des_ps.pre < prev    next >
Text File  |  1994-07-01  |  28KB  |  1,107 lines

  1. %-----------------------------------------------------------------------------
  2. % 9999.17 GST 194 - PostScript Preamble file for GST DesignWorks
  3. %-----------------------------------------------------------------------------
  4. % This file is inserted as the prolog when Artwork saves an EPSF file.
  5. % The program generates the initial structure comments required by EPSF
  6. % and strips comments from this file as it merges it into its output.
  7. % The main part of the job is put between the 'EndSetup' and 'Trailer' lines.
  8. %-----------------------------------------------------------------------------
  9. % Naming conventions: 
  10. % Names in all lowercase are executable procedures, like built-in postscript
  11. % procedures. Names with the first letter capitalised are variables. Names 
  12. % ending in a question mark are boolean: they can have values T or F
  13. %-----------------------------------------------------------------------------
  14. % version 0.29 1.July.94
  15. % NOTE: comments are stripped before printing!
  16. %-----------------------------------------------------------------------------
  17. %
  18. % ArtProcsDict contains all the procedures defined in this prolog
  19. % and must also have enough room for special postscript fill & line style procs.
  20. % ArtVarsDict contains all the variables etc used by the procedures.
  21.  
  22. /ArtProcsDict 160 dict def  
  23. /ArtVarsDict 100 dict def  
  24.  
  25. %---- optional jobtimeout 
  26. ArtVarsDict begin 
  27.    /Timeout 0 def 
  28. end
  29.  
  30. ArtProcsDict begin
  31.  
  32. %----- abbreviations -----%
  33.  
  34.  /bd { bind def } bind def
  35.  /ed { exch def } bd
  36.  /np /newpath load def
  37.  /cp /closepath load def
  38.  /gs { /SavePrint? Print? def gsave } bd
  39.  /gr { /Print? SavePrint? def grestore } bd
  40.  
  41.  /SS{}def
  42.  /RS{}def
  43.  /SM{}def
  44.  
  45. %----- misc tiny routines -----%
  46.  
  47. % specialscreen? returns YES if screen frequency <= 30
  48.  /specialscreen? { currentscreen pop pop 30 lt } bd
  49.  /min{2 copy gt{exch}if pop}bd % minimum of top 2 items on stack
  50.  /max{2 copy lt{exch}if pop}bd % maximum ditto
  51.  /maxof4 { 3{max}repeat } bd
  52.  /pt { 1000 mul 72 div } bd % converts points
  53.  /beginlayer { pop /LayerSave save def } bd %% layer number ignored
  54.  /endlayer { LayerSave restore } bd
  55.  
  56.  
  57. %----- path construction -----%
  58.  
  59. % P: adjusts positions of thin lines 
  60.  /p { transform round .4 add exch round .4 add exch itransform } bd
  61.  /c { p curveto } bd /m { p moveto } bd /l { p lineto } bd
  62.         
  63.  
  64. %---------- Colour handling ----------%
  65. %
  66. % define setcmykcolor if not implemented in printer. 
  67.  
  68. /mysetcmykcolor { % convert CMYK to RGB for monochrome printer
  69.   4 1 roll
  70.   3 {
  71.     3 index add 1 exch sub
  72.     dup 0 lt{pop 0}if
  73.     3 1 roll
  74.   } repeat
  75.   setrgbcolor pop
  76. } bd
  77.  
  78. /initcmykcolor {
  79.   /setcmykcolor where dup
  80.   /BwPrinter? exch not def
  81.   { 
  82.     pop 
  83.   }{
  84.     /setcmykcolor /mysetcmykcolor load def
  85.   } ifelse
  86. } bd
  87.  
  88.  
  89. %----- SETCMYK -----%
  90. % setcmyk is a low-level routine, called whether or not the 
  91. % printer supports colour.
  92. % It is at this level that we perform process colour separation.
  93. % We save the current CMYK setting, and routine currentcmyk can
  94. % be called to enquire the setting.
  95.  
  96. /setcmyk { 
  97.   4 copy SaveCmyk astore pop 
  98.   Comp? {               % printing a monochrome or colour composite
  99.     BwPrinter? specialscreen? and
  100.     {
  101.         % printing a special screen on a monochrome composite
  102.         % don't convert cmyk, as we'll end up with stripes or dots
  103.         % which are too small: convert the largest process colour
  104.         % component to gray. (Still not completely correct)
  105.         maxof4 1 exch sub setgray
  106.     }{
  107.       setcmykcolor 
  108.     } ifelse
  109.   }{
  110.     SpotSep? {          % if printing a spot-colour separation
  111.       blank pop         % print blank (clear or white, depending on overprint flag) 
  112.     }{                  % else printing a a process separation
  113.       4 Separation roll % bring one sep to top
  114.       dup 0 eq { 
  115.         blank pop 
  116.       }{ 
  117.         1 exch sub setgray 
  118.       } ifelse
  119.     } ifelse
  120.     pop pop pop         % clear c,m,y from stack
  121.   } ifelse
  122. } bd
  123.  
  124.  
  125. /currentcmyk {
  126.   SaveCmyk aload pop
  127. } bd
  128.  
  129.  
  130. %----- APPLYTINT -----%
  131. %
  132. % This is a lower-level colour interface
  133. % which can apply a percentage tint to a set
  134. % of CMYK percentage values.
  135. %
  136. % stack: t% c% m% y% k%
  137.  
  138. /applytint {
  139.   4{ 
  140.     4 index mul 
  141.     10000 div 
  142.     4 1 roll 
  143.   }repeat 
  144.   setcmyk 
  145.   pop 
  146. } bd
  147.  
  148.  
  149.  
  150. /blank { 
  151.   1 setgray 
  152.   /Print? OverPrint? not def 
  153.   0 0 0 0 SaveCmyk astore pop
  154. } bd
  155.  
  156.  
  157. /setgraytint {
  158.   dup 0 eq { OverPrint? not } { T } ifelse 
  159.   /Print? ed
  160.   dup /SpotTint ed
  161.   100 div 1 exch sub setgray
  162. } bd
  163.  
  164.  
  165. %----- COLPROCS -----%
  166. % Colprocs is a dictionary containing different procedures for 
  167. % setcolour to execute, depending on the type of the object 
  168. % on top of the stack when setcolour is called.
  169. % Colours is a dictionary of user-defined colours, indexed by name,
  170. % containing 2-level [ [C M Y K] spot? ] arrays with values in range 0-100
  171.  
  172. /Colprocs 4 dict def 
  173. Colprocs begin
  174.  
  175.   /arraytype {                          % [ C M Y K ] process colour mix
  176.       100 exch aload pop applytint      % apply 100% tint to the mix
  177.   } bd
  178.  
  179.   % perform spot-colour separation 
  180.   /nametype {                   % stack: tint name
  181.     dup Colours exch get        % tint name [ [ C M Y K ] Spot? ]
  182.     1 get not Comp? or {        % if not a spot colour, or printing composite
  183.       Colours exch get          % tint [ [ C M Y K ] Spot? ]
  184.       0 get aload pop           % tint c m y k
  185.       applytint 
  186.     }{                          % else spot colour & not composite printout
  187.       SpotSep? {                % if printing a spot separation...
  188.         Separation eq {            % is spot colour same as this separation?
  189.           setgraytint           % if so, set percentage tint
  190.         }{
  191.           pop blank             % wrong spot sep: print nothing
  192.         } ifelse
  193.       }{
  194.         pop pop blank           % printing a process sep: print nothing
  195.       } ifelse
  196.     } ifelse
  197.   } bd
  198.  
  199.   /integertype {                % apply percentage tint to black
  200.     0 0 0 100 applytint 
  201.   } bd
  202.  
  203.   /realtype /integertype load def
  204. end % Colprocs
  205.  
  206.  
  207.  
  208. %----- SETCOLOUR -----%
  209. %
  210. % This routine is the top-level color interface. 
  211. % It can be called in three different ways:
  212. %   number      SETCOLOUR --  % number is %black, 0=white 100=black
  213. %   [ 4-array ] SETCOLOUR --  % array contains C M Y K percentages
  214. %   number name SETCOLOUR --  % percentage tint of a named colour
  215.  
  216. /setcolour { 
  217.   /Print? T def
  218.   /SpotTint 0 def % preset spot colour tint value to zero
  219.   dup type Colprocs exch get exec 
  220. } bd
  221.  
  222.  
  223.  
  224. %----- FILL and STROKE -----%
  225. %
  226. % Winding? is a boolean which selects whether we use the winding-number fill
  227. % or the even-odd fill algorithm. Print? is a boolean used to enable or 
  228. % disable fill and stroke when overprinting separations, set by setcolour 
  229. % and blank.
  230.  
  231.  /ovp { /OverPrint? ed } bd
  232.  /wif { /Winding? T def } bd
  233.  /eof { /Winding? F def } bd
  234.  
  235.  /~stroke { Print? { stroke } if } bd
  236.  /_stroke { setcolour ~stroke } bd
  237.  /~fill { Print? { Winding? { fill } { eofill } ifelse } if } bd
  238.  /_fill { setcolour ~fill } bd
  239.  /_clip { Winding? { clip } { eoclip } ifelse } bd
  240.  
  241.  /sml { 2 div sin 1 exch div setmiterlimit } bd
  242.  /sline { setlinewidth setlinejoin setlinecap } bd
  243.  /li { Lines exch get exec } bd
  244.  /fi { Fills exch get exec } bd
  245.  
  246.  
  247.  
  248. %----- GROUPS -----%
  249.  
  250.  /bg { gsave concat } bd % matrix BG -- 
  251.  /eg { grestore } bd 
  252.  
  253.  
  254.  
  255. %----- Utility Routines -----%
  256.  
  257.  /getbox { /Top ed /Right ed /Bottom ed /Left ed } bd 
  258.  
  259.  /arcpop { arcto 4 { pop } repeat } bd
  260.  
  261.  
  262.  
  263. %----- basic shapes: ROUND BOX -----%
  264.  
  265. /shape_rbox {
  266.   /Rad ed
  267.   getbox
  268.   matrix currentmatrix
  269.     exch concat
  270.     np Left Right add 2 div Top p moveto % top centre
  271.     Right Top p Right Bottom p Rad arcpop
  272.     Right Bottom p Left Bottom p Rad arcpop
  273.     Left Bottom p Left Top p Rad arcpop
  274.     Left Top p Right Top p Rad arcpop cp 
  275.   setmatrix
  276. } bd
  277.  
  278.  
  279.  
  280. %----- basic shapes: BOX -----%
  281. /boxpath {
  282.   np Left Top m Right Top l
  283.   Right Bottom l Left Bottom l cp
  284. } bd
  285.  
  286. /shape_box {
  287.   getbox
  288.   matrix currentmatrix
  289.     exch concat boxpath
  290.   setmatrix
  291. } bd
  292.  
  293.  
  294. /clip_box { getbox boxpath eoclip } bd
  295.  
  296.  
  297.  
  298. %----- basic shapes: ELLIPSE -----%
  299.  
  300. /shape_ellipse {
  301.   getbox
  302.   matrix currentmatrix 
  303.     exch concat
  304.     % map unit circle to bounding box
  305.     Left Top translate
  306.     Right Left sub Bottom Top sub scale
  307.     np .5 .5 .5 0 360 arc cp
  308.   setmatrix
  309. } bd
  310.  
  311.  
  312. %----- IMAGES -----%
  313.  
  314. /artimage {
  315.   gs
  316.     /Bgd? exch def
  317.     /Mask? exch def
  318.     /Bits exch def 
  319.     /Height exch def
  320.     /Width exch def
  321.     getbox concat 
  322.  
  323.     Bgd? { setcolour boxpath wif ~fill } if
  324.  
  325.     Left Top translate 
  326.     Right Left sub 
  327.     Bottom Top sub scale
  328.  
  329.     Mask? {   
  330.       setcolour
  331.         Width Height true [ Width 0 0 Height 0 0 ] 
  332.         { currentfile ImageBuff readhexstring pop }
  333.       imagemask
  334.     }{  Width Height Bits [ Width 0 0 Height 0 0 ] 
  335.         { currentfile ImageBuff readhexstring pop }
  336.       image
  337.     } ifelse
  338.   gr
  339. } bd    
  340.  
  341.  
  342. /densitylookup {
  343.    densitygreys 1 sub mul cvi  % convert input grey level to integer
  344.    densityarray exch get   % lookup value (range 0..2000)
  345.    1000 div             % convert to density 0.0-2.0
  346.    neg 10 exch exp      % reflectance = 10 ^ -density
  347. } bd
  348.  
  349. /palettelookup {
  350.    palettecols 1 sub mul cvi  % convert input grey level to integer
  351.    palettearray exch get   % lookup value (range 0..1000)
  352.    1000 div             % convert to reflectance 0..1
  353. } bd
  354.  
  355. /artcolimage {
  356.   gs
  357.     /Proc exch load def 
  358.     /Height ed /Width ed
  359.     getbox concat            
  360.     Left Top translate 
  361.     Right Left sub 
  362.     Bottom Top sub scale
  363.  
  364.     /Im? T def
  365.     /Wn Width def
  366.  
  367.     Width Height 8 [ Width 0 0 Height 0 0 ] 
  368.     /Proc load 
  369.     false 3 colorimage
  370.  
  371.     gr
  372. } bd    
  373.  
  374. /img4 {
  375.  Im? {
  376.    % read one byte from the file
  377.    currentfile ImageBuff readhexstring pop 
  378.    0 get -4 bitshift
  379.  }{
  380.    ImageBuff 0 get
  381.  }ifelse
  382.  
  383.  %--- see if we're at the end of a raster line
  384.  Wn 1 sub dup 0 eq { pop Width T }{ Im? not } ifelse
  385.  /Im? ed /Wn ed
  386.  
  387.  % use result as index into palette
  388.  15 and palettearray exch get 
  389. } bd
  390.  
  391.  
  392. /img8 {
  393.    currentfile ImageBuff readhexstring pop % read one byte from the file
  394.    0 get palettearray exch get % use that as index into palette
  395. } bd
  396.  
  397. /img24 {
  398.    currentfile ImageRgbBuff readhexstring pop % read 3 bytes from the file
  399. } bd
  400.  
  401.  
  402. %----- normalised transfer function -----%
  403.  
  404. /normalise
  405. {
  406.   mark
  407.   1.0 1.0 .98 .9 .82 .68 
  408.   .56 .48 .28 .1 .06 .0                 % i [ nvalues
  409.   counttomark                           % i [ nvalues n
  410.   dup 3 add -1 roll exch                % [ nvalues input n
  411.   2 sub mul                             % [ nvalues j     % j = (n-2)*i k=floor(j)
  412.   dup floor cvi                         % [ nvalues j k
  413.   dup 3 1 roll sub                      % [ nvalues k j-k
  414.   exch dup                              % [ nvalues j-k k k
  415.   3 add index exch 2 add index dup      % [ nvalues j-k table[k+1] table[k] table[k]
  416.   4 1 roll                              % [ nvalues table[k] j-k table[k+1] table[k]
  417.   sub mul add                           % [ nvalues result    % result = ( table[k] + (j-k)*(table[k+1]-table[k]) )
  418.   counttomark 1 add 1 roll              % result [ nvalues
  419.   cleartomark                           % result
  420. } bd
  421.  
  422.  
  423. /?Negative {} bd % if printing negative, this procedure changes
  424.  
  425. /neg_transfer { 
  426.   /?Negative { 1 exch sub } bd 
  427.   {  ?Negative normalise DefTran } bind settransfer   
  428.   gs clippath 1 setgray fill gr              % then fill with white
  429.   
  430. } bd
  431.  
  432. %----- Special Effects: Flatten Path -----%
  433. %
  434. % flatten path, adjust 'setflat' until it works.
  435. % no parameters, no output. NOTE: this leaves a 'gs' in effect
  436.  
  437. /flatclip { 
  438.   currentflat
  439.   { 
  440.     gs
  441.     { flattenpath _clip } stopped not {exit}if
  442.     % ie, if not stopped due to error, exit loop
  443.     
  444.     % but if the error was other than limitcheck, stop now!
  445.     $error /errorname get /limitcheck ne { stop } if
  446.  
  447.     % if flatness gets too high, give up
  448.     currentflat 80 gt { exit } if
  449.     
  450.     % try again with flatter paths
  451.     gr currentflat 1.1 mul 1 add setflat
  452.   }loop
  453.   setflat
  454. } bd
  455.  
  456. /flatp { 
  457.   currentflat
  458.   { {flattenpath} stopped not {exit}if
  459.     currentflat 1 add setflat
  460.   }loop
  461.   setflat
  462. } bd
  463.  
  464.  
  465.  
  466. %----- Special Effects: Clip to Path -----%
  467. %
  468. % Also computes bounding box and width and height.
  469. % NOTE: flatclip saves graphics state
  470.  
  471. /clipper {
  472.   pathbbox flatclip
  473.   /Bottom ed /Right ed /Top ed /Left ed
  474.   Right Left sub /Width ed
  475.   Bottom Top sub /Height ed
  476. } bd
  477.  
  478.  
  479.  
  480.  
  481. %----- Example of a special fill routine -----%
  482.  
  483. /examplefill {
  484.   clipper %gs implied
  485.     Left Top translate
  486.     % insert commands to fill area from (0,0) to (Width,Height)
  487.     Width Height scale
  488.     % or insert commands to fill unit square
  489.   gr
  490. } bd
  491.  
  492.  
  493.  
  494. %----- Graduated Fill Support Code -----%
  495.  
  496. /GradFillDict 30 dict def
  497.  
  498. /GrayProcs [ 
  499.   {} % 0: radial
  500.   {dup mul} bind % 1: spherical 
  501.   {} % 2
  502.   {} % 3: linear
  503.   {9 mul 1 add log} bind % 4: logarithmic
  504.   {dup 1 exch sub mul 4 mul} bind % 5: cylindrical 
  505. ] def
  506.  
  507. /grayconv { % start diff ingray GRAYCONV outgray 
  508.   GrayProcs GradType get exec
  509.   mul add
  510. } bd
  511.  
  512.  
  513. /grad_common_init {
  514.   %---- initialise variables in local dictionary
  515.  
  516.   % convert start colour to CMYK and get values
  517.   setcolour 
  518.   SpotSep? not {
  519.     currentcmyk 
  520.     /StartK ed /StartY ed /StartM ed /StartC ed
  521.   } if
  522.   /StartT SpotTint def
  523.  
  524.   % do the same for the end colour
  525.   setcolour 
  526.   SpotSep? not {
  527.     currentcmyk
  528.     /EndK ed /EndY ed /EndM ed /EndC ed
  529.   } if
  530.   /EndT SpotTint def 
  531.  
  532.   % replace End with End-Start
  533.   SpotSep? not {
  534.     /EndC EndC StartC sub def
  535.     /EndM EndM StartM sub def
  536.     /EndY EndY StartY sub def
  537.     /EndK EndK StartK sub def
  538.   } if
  539.   /EndT EndT StartT sub def
  540.  
  541.  
  542.   % If printing colour separations, if the separation has
  543.   % the same tint for the start and end of the grad fill,
  544.   % treat it as a solid fill to save time.
  545.  
  546.   /SolidFill? F def
  547.  
  548.   Comp? not {           % not printing a composite - separations
  549.  
  550.     SpotSep? {          % printing a spot colour sep
  551.       StartT setgraytint
  552.       EndT 0 eq /SolidFill? ed
  553.     }{                  % printing a process sep
  554.       mark
  555.       StartC StartM StartY StartK 4 Separation roll
  556.       100 mul setgraytint % 0.22
  557.  
  558.       EndC EndM EndY EndK 4 Separation roll
  559.       0 eq /SolidFill? ed
  560.       
  561.       cleartomark
  562.     } ifelse
  563.  
  564.   } if
  565. } bd
  566.  
  567.  
  568. /grad_common_middle {
  569.   /X ed
  570.   SpotSep? {
  571.     StartT EndT X grayconv
  572.     setgraytint 
  573.   }{
  574.     StartC EndC X grayconv
  575.     StartM EndM X grayconv
  576.     StartY EndY X grayconv
  577.     StartK EndK X grayconv
  578.     setcmyk
  579.   } ifelse
  580. } bd
  581.  
  582.  
  583.  
  584.  
  585. %----- Graduated Fill: linear, logarithmic, cylindrical -----%
  586. %
  587. % parameters: angle type startcolour endcolour
  588. % each colour can be either a number (for a black tint)
  589. % a number and a name, or an array of four values: 
  590. % the same as setcolour.
  591. % type: 3=linear 4=logarithm 5=cylinder
  592.  
  593. /linfill {
  594.   GradFillDict begin
  595.   grad_common_init
  596.   /GradType ed
  597.   neg /Theta ed
  598.   /Steps GradType 3 ne { 200 } { 100 } ifelse def
  599.   % also uses Top Bottom Left Right Width Height in dictionary
  600.  
  601.   SolidFill? {
  602.  
  603.     ~fill       % separation, and fill is solid for this sep
  604.   }{
  605.  
  606.     %---- prepare to fill to clipping path 
  607.     %     and setup transformation matrix
  608.     gs
  609.       Theta rotate 
  610.       clipper %gs implied
  611.       Left Top translate
  612.       Width Height scale
  613.       1 Steps 1 add div setlinewidth
  614.  
  615.       0 1 Steps { 
  616.         dup Steps div
  617.  
  618.         grad_common_middle
  619.  
  620.         newpath
  621.           .5 add 
  622.           Steps 1 add 
  623.         div 0
  624.         moveto 
  625.  
  626.         0 1 rlineto
  627.         ~stroke
  628.  
  629.       } bind for
  630.     gr gr
  631.  
  632.   }ifelse
  633.  
  634.   end
  635. } bd
  636.  
  637.  
  638. %----- Radial/Spherical Graduated Fill -----%
  639. %
  640. % stack: type startcolour endcolour
  641. % type: 0=radial, 1=spherical
  642.  
  643. /radfill { 
  644.   GradFillDict begin
  645.   grad_common_init
  646.   /GradType ed
  647.   /Steps GradType 0 ne { 200 } { 100 } ifelse def
  648.  
  649.   SolidFill? {
  650.     ~fill       % separation, and fill is solid for this sep
  651.   }{
  652.  
  653.     clipper %gs implied
  654.       Left Right add 2 div Top Bottom add 2 div translate % centre
  655.       Width dup mul Height dup mul add sqrt 2 div dup scale % half diagonal
  656.       Steps -1 1 { % loop to fill unit circle centred on origin
  657.         /Rad exch Steps div def
  658.  
  659.         Rad grad_common_middle
  660.  
  661.         np 0 Rad moveto 0 0 Rad 0 360 arc cp
  662.         ~fill
  663.       } bind for
  664.     gr
  665.  
  666.   } ifelse
  667.  
  668.   end
  669. } bd
  670.  
  671. %----- Arrowheads -----------
  672.  
  673. /ArrowProcs [
  674. {} 
  675. {np 0 25 m 50 0 l 0 -25 l cp fill }   
  676. {np 0 25 m 50 0 l 0 -25 l cp stroke } 
  677. {np 0 0 m -10 25 l 50 0 l -10 -25 l cp fill }
  678. {np 5 0 m -5 25 l 50 0 l -10 -25 l cp stroke }
  679. {np -45 25 m 5 0 l -45 -25 l stroke }
  680. {np 0 25 m 0 -25 l stroke }
  681. {np 2 setlinejoin -50 25 m 0 0 l -50 -25 l 0 25 m 0 -25 l stroke }
  682. {np 50 25 m 0 0 l 50 -25 l stroke }
  683. {np 100 25 m 50 0 l 100 -25 l 50 0 m 0 0 l 50 25 m 0 0 l 50 -25 l stroke }
  684. {np 100 25 m 50 0 l 100 -25 l 45 -25 l 0 -5 l 0 5 l 45 25 l cp fill }
  685. ] def
  686.  
  687. % type dx dy scale x y arrow
  688.  
  689. /arrow {
  690.   gs
  691.     translate 
  692.     dup 20 lt { pop 20 } if
  693.     10 div dup scale 
  694.     exch atan 180 add rotate
  695.     0 0 10 sline
  696.     Print? {
  697.       ArrowProcs exch get exec
  698.     }{
  699.       pop
  700.     } ifelse
  701.     gr
  702. } bd
  703.  
  704.  
  705.  
  706. %----- Tiled Fill -----------
  707.  
  708. /TiDict 20 dict def
  709.  
  710. /tipos {        % pos wid
  711.   dup           % pos wid wid
  712.   3 1 roll      % wid pos wid
  713.   div floor mul % pos'
  714. } bd
  715.  
  716. /_tile { % dx dy proc scaledwidth scaledheight scale(percent) angle
  717.   TiDict begin
  718.   /TiAngle ed 
  719.   100 div /Tscale ed
  720.   Tscale div /TiHgt ed 
  721.   Tscale div /TiWid ed 
  722.   /TiProc ed
  723.   % leave just dx & dy on stack
  724.  
  725.   gs 1 setgray ~fill gr % 0.18: fill shape with white
  726.  
  727.   gs
  728.     translate TiAngle neg rotate Tscale dup scale
  729.     flatclip pathbbox /TiBottom ed /TiRight ed /TiTop ed /TiLeft ed
  730.     TiTop TiHgt tipos TiHgt TiBottom {
  731.       gs 0 exch translate
  732.         TiLeft TiWid tipos TiWid TiRight {
  733.           gs 0 translate /TiProc load 
  734.           ArtVarsDict begin exec end gr
  735.         } for
  736.       gr
  737.     }for
  738.   gr gr
  739.   end
  740. } bd
  741.  
  742.  
  743. %--------- TEXT HANDLING -----------%
  744.  
  745.  /begintext { matrix currentmatrix } bd % leave current matrix on top of stack
  746.  /endtext { setmatrix } bd     % restore saved matrix
  747.  /ntm { exch dup setmatrix exch concat } bd % newtextmatrix: matrix
  748.  
  749.  
  750.  /textstyle { % proc
  751.   /SimpleText? F def
  752.   /filltext exch bind def
  753.  } bd
  754.  
  755.  /plaintext { % <colour & tint>
  756.   F ovp
  757.   setcolour
  758.   /SimpleText? T def
  759.  } bd
  760.  
  761. /tf { % textfont: size width fontname
  762.   findfont 3 1 roll
  763.   exch neg matrix scale makefont
  764.   setfont
  765. } bd
  766.  
  767. /txt { % x y string
  768.   3 1 roll moveto
  769.   SimpleText?
  770.   {
  771.     Print? { show } if
  772.   }{
  773.     {
  774.       currentpoint np moveto
  775.       tempstr 0 2 index put 
  776.       tempstr T charpath filltext
  777.       pop
  778.     } forall
  779.   } ifelse
  780. } bd
  781.  
  782. /filltext { } def
  783.  
  784.  
  785. /title { 
  786.   gs
  787.   moveto
  788.   {270 rotate} if
  789.   100 pt exch div dup neg scale
  790.   /Helvetica findfont 10 scalefont setfont
  791.   show
  792.   gr
  793. } bd
  794.  
  795. /regmark {
  796.   gs translate 
  797.   1 setlinewidth
  798.   np -100 0 moveto 100 0 lineto stroke
  799.   np 0 -100 moveto 0 100 lineto stroke
  800.   np 0 0 50 0 360 arc stroke
  801.   gr
  802. } bd
  803.  
  804. /cropmark {
  805.   gs 1 setlinewidth np moveto lineto stroke gr
  806. } bd
  807.  
  808. %----- Routines to rearrange font to match Windows Ansi character set -----%
  809.  
  810. /ANSI_Vec [
  811.  /grave/acute/circumflex/tilde/macron/breve/dotaccent/dieresis
  812.  /ring/cedilla/hungarumlaut/ogonek/caron/dotlessi/.notdef/.notdef
  813.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  814.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  815.  /space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quotesingle
  816.  /parenleft/parenright/asterisk/plus/comma/hyphen/period/slash
  817.  /zero/one/two/three/four/five/six/seven
  818.  /eight/nine/colon/semicolon/less/equal/greater/question
  819.  /at/A/B/C/D/E/F/G
  820.  /H/I/J/K/L/M/N/O
  821.  /P/Q/R/S/T/U/V/W
  822.  /X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore
  823.  /grave/a/b/c/d/e/f/g
  824.  /h/i/j/k/l/m/n/o
  825.  /p/q/r/s/t/u/v/w
  826.  /x/y/z/braceleft/bar/braceright/asciitilde/.notdef
  827.  
  828.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  829.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  830.  
  831.  /.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet/endash/emdash
  832.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  833.   
  834.  /space/exclamdown/cent/sterling/currency/yen/brokenbar/section
  835.  /dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron
  836.  /degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered
  837.  /cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown
  838.  /Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
  839.  /Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis
  840.  /Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply 
  841.  /Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
  842.  /agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
  843.  /egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
  844.  /eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide 
  845.  /oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
  846. ] def
  847.  
  848.  
  849. /ReEncDict 12 dict def
  850.  
  851. /ischar {
  852.   BaseFontDict /CharStrings get exch known
  853. }bd
  854.  
  855. /mapch {
  856.   dup ischar not 
  857.   {pop /.notdef} if 
  858.   NewFont /Encoding get 3 1 roll put 
  859. }bd
  860.  
  861. /mapdegree{ 16#b0 /degree ischar {/degree}{/ring} ifelse mapch } bd
  862.  
  863. /mapbb { 16#a6 /brokenbar ischar {/brokenbar}{/bar}ifelse mapch } bd
  864.  
  865. /reencoderange {  
  866.   { dup ANSI_Vec exch get mapch } for
  867. } bd
  868.  
  869. /reencode {
  870.   0 1 15 reencoderange
  871.   144 1 255 reencoderange
  872.   16#27 /quotesingle mapch
  873.   16#60 /grave mapch
  874.   16#7C /bar mapch
  875.   mapdegree mapbb
  876. } bd
  877.  
  878. /ansifont {
  879.  ReEncDict begin
  880.    /NewFontName exch def 
  881.    /BaseFontName exch def
  882.    FontDirectory NewFontName known not
  883.    {
  884.      /BaseFontDict BaseFontName findfont def
  885.      /NewFont BaseFontDict maxlength dict def
  886.      BaseFontDict {
  887.        exch dup /FID ne { 
  888.          dup /Encoding eq { 
  889.            exch 
  890.            dup length array copy 
  891.            NewFont 3 1 roll put 
  892.          }{ 
  893.            exch 
  894.            NewFont 3 1 roll put 
  895.          }
  896.          ifelse
  897.        }{
  898.          pop pop
  899.        }ifelse
  900.      }forall
  901.      NewFont /FontName NewFontName put
  902.  
  903.      % look at the charstrings see if it has 'A' and 'Z':
  904.      % if so, remap the font. If not, leave it alone!
  905.      /A ischar /Z ischar and { reencode } if
  906.      NewFontName NewFont definefont pop
  907.    } if
  908.    NewFontName
  909.  end
  910. } bind def
  911.  
  912.  
  913. %----- Colour Separation Setup Procedures -----%
  914. %
  915. % Separation: if undefined, a composite is produced
  916. %       if numeric, a process colour separation is produced
  917. %               3=cyan, 2=magenta, 1=yellow, 0=black
  918. %       if a name of a spot colour, that spot separation is produced
  919. %
  920. % example:
  921. %       /Separation 3 def setupsep 
  922. %       /Separation /Reflex_Blue def setupsep
  923.  
  924.  
  925. /setupsep {
  926.   /Separation where {           % is 'Separation' defined?
  927.     pop
  928.     /Comp? F def                % yes: we're doing a separation.
  929.     Separation type             % is it a number?
  930.     0 type ne 
  931.     /SpotSep? ed          % if not, we're doing a spot colour.
  932.   }{
  933.     /Comp? T def                % separation not defined: doing a composite.
  934.     /SpotSep? F def
  935.   } ifelse
  936.  
  937.   statusdict begin Timeout setjobtimeout end % timeout per separation
  938.  
  939. } bd
  940.  
  941.  
  942. /setsepscreen { AngleFix add /DefScrFun load setscreen } bd
  943.  
  944.  
  945. %---------- included EPSF procedure
  946.  
  947. /include_epsf {
  948.   /Bottom ed /Left ed 
  949.   gsave concat
  950.  
  951.   % assumes that bottom-left of rect corresponds to EPSF's origin
  952.   Left Bottom translate
  953.   1000 72 div dup neg scale
  954.  
  955.   /EpsfSave save def
  956.  
  957.   /showpage { } def
  958.  
  959.   currentfile cvx stopped { % did it stop?
  960.     $error /newerror get {  % was it a new error?
  961.       handleerror           % put out an error message
  962.  
  963.       % skip to end of included file
  964.       { % loop
  965.         currentfile LineBuff readline {
  966.           (\045\045EndEPSF) eq { exit } if
  967.         }{
  968.           % can't find end marker - hit EOF?
  969.         } ifelse
  970.       } loop
  971.  
  972.     } if
  973.   }{
  974.     % didn't stop - hit EOF?
  975.   } ifelse
  976.   $error /newerror F put
  977.  
  978.   EpsfSave restore
  979.   grestore
  980. } bd
  981.  
  982. %--------------------------------- downloaded font stuff -------------------
  983.  
  984. /BuildDict 3 dict def
  985.  
  986. /PointProcs[{}{closepath moveto}bind/lineto load/curveto load]def
  987.  
  988. /gst_char { gstn 8 bitshift add /gstn ed /gsti gsti 1 add def
  989. gsti 3 eq {
  990.   gstn 2047 and dup 1600 gt { 2048 sub } if
  991.   gstn -11 bitshift 2047 and dup 1600 gt { 2048 sub } if
  992.   gstn -22 bitshift 3 and PointProcs exch get exec
  993.   /gstn 0 def /gsti 0 def
  994.   } if
  995. } bd
  996.  
  997. /gst_build { 
  998. exch begin 
  999.   BuildDict begin 
  1000.     Encoding exch get 
  1001.     /gstn 0 def /gsti 0 def
  1002.     dup Metrics exch get 0 setcharwidth 
  1003.     newpath CharStrings exch get { gst_char } forall 
  1004.     closepath fill 
  1005.   end 
  1006. end
  1007. } bd
  1008.  
  1009. /gst_fast { 
  1010. exch begin 
  1011.   Encoding exch get 
  1012.   dup Metrics exch get 0 setcharwidth 
  1013.   CharStrings exch get cvx exec 
  1014. end
  1015. } bd
  1016.  
  1017. /newgstfont {
  1018.   ReEncDict begin
  1019.   /NewFontSize ed
  1020.   /NewFontId ed
  1021.   /NewFontFast ed
  1022.   /NewFontName ed
  1023.   10 dict dup begin
  1024.     /FontMatrix [ .001 0 0 .001 0 0 ] def
  1025.     /FontType 3 def
  1026.     /FontBBox [ -400 -300 1600 1000 ] def
  1027.     /Encoding ANSI_Vec def
  1028.     /Metrics NewFontSize dict def Metrics /.notdef 0 put
  1029.     /CharStrings NewFontSize dict def CharStrings /.notdef () put
  1030.     /UniqueID 16#ff0000 NewFontId add def
  1031.     /gst_fast /gst_build NewFontFast { exch } if load /BuildChar ed pop
  1032.   end
  1033.   NewFontName exch definefont pop
  1034.   NewFontName
  1035. end
  1036. } bd
  1037.     
  1038. /NewCharDict 4 dict def
  1039.  
  1040. /newchar { 
  1041. NewCharDict begin
  1042.   /Proc ed
  1043.   /Wid ed
  1044.   /Code ed
  1045.   dup findfont begin
  1046.     Encoding Code get dup
  1047.     CharStrings exch /Proc load put
  1048.     Metrics exch Wid put
  1049.   end
  1050. end
  1051. } bd
  1052.  
  1053.  
  1054. %%EndProlog
  1055.  
  1056. %%BeginSetup
  1057.  
  1058. /ArtworkSave save def
  1059.   ArtVarsDict begin
  1060.  
  1061.   % boolean abbreviations
  1062.   /T true def /F false def
  1063.  
  1064.   % initialise default line end, join, mitre limit etc
  1065.   1 1 14 sline 10 sml
  1066.  
  1067.   % initialise misc variables
  1068.   /tempstr 1 string def         % buffer for text
  1069.   /ImageBuff 1 string def       % buffer for bitmap images
  1070.   /ImageRgbBuff 3 string def    % buffer for bitmap images
  1071.   /LineBuff 256 string def      % buffer for included epsfs
  1072.   /SimpleText? T def            % flag for fast text handling
  1073.   /Wind? T def                  % winding fill on/off
  1074.   /Print? T def                 % print flag used by colour separation stuff
  1075.   /SaveCmyk 4 array def         % current C,M,Y,K colour
  1076.   /Imat matrix identmatrix def  % an indentity matrix
  1077.   /bignum 2 31 exp 1 sub def    % for random number generator
  1078.   initcmykcolor
  1079.  
  1080.   % determine current transformation's rotation, (eg for landscape)
  1081.   % which will need to be applied to any screen angles
  1082.   /AngleFix 1 0 dtransform exch atan def
  1083.  
  1084.   % record the current screen function, angle and frequency
  1085.   currentscreen /DefScrFun exch def pop pop
  1086.   ArtProcsDict /Screens known {
  1087.     currentscreen Screens exch 0 exch put pop pop
  1088.   } if
  1089.  
  1090.   % record the current transfer function, and set up a normalised
  1091.   % transfer function followed by the default
  1092.   /DefTran currenttransfer def
  1093.   {normalise DefTran}bind settransfer
  1094.  
  1095.  
  1096. %%EndSetup
  1097.  
  1098. %%Trailer
  1099. end % ArtVarsDict
  1100. ArtworkSave restore
  1101. end % ArtProcsDict
  1102. %%EOF
  1103.  
  1104.  
  1105.