home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / dvips583.zip / contrib.zip / dvips / contrib / crop.lpr < prev    next >
Text File  |  1998-11-03  |  10KB  |  272 lines

  1. %!
  2. %   This file is for crop marks and registration marks if there is color.
  3. %
  4. %   First, we translate and draw the marks.  You can change the way the
  5. %   marks are drawn, but the quarter inch border around the page is fixed.
  6. %
  7. %   This file uses bop-hook; sorry.
  8. %
  9. TeXDict begin
  10. %
  11. % CM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12. %                                                                            %
  13. % x_center y_center  CM  -                                                   %
  14. %                                                                            %
  15. % Make a crop mark at x_center y_center.  This crop mark is just a cross.    %
  16. % Checks to see if TeXcolorcmyk is defined---if there is no color, you can   %
  17. % setgray instead of setcmykcolor.                                           %
  18. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  19. /cX 18 def      % the crop offset
  20. /CM
  21. {
  22.    gsave
  23.       3 1 roll
  24.       translate
  25.       rotate
  26.       .3 setlinewidth
  27.       /TeXcolorcmyk where {pop 1 1 1 1 setcmykcolor} {0 setgray} ifelse
  28.       0 cX neg moveto
  29.       0 cX 2 div neg lineto stroke
  30.       cX neg 0 moveto
  31.       cX 2 div neg 0 lineto stroke
  32.    grestore
  33. } def
  34. %
  35. % RegMark %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  36. %                                                                            %
  37. % x_center y_center  RegMark  -                                              %
  38. %                                                                            %
  39. % Make a registration mark at x_center y_center.  Consists of two concentric %
  40. % circles, the inner one filled, and a cross hair through them.  Preferred   %
  41. % by those who register films for proof.  Checks to see if TeXcolorcmyk is   %
  42. % defined---if there is no color, you don't need registration marks!         %
  43. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  44. /RegMark
  45. {
  46.    /TeXcolorcmyk where
  47.    {
  48.       pop
  49.       gsave
  50.          translate
  51.          .3 setlinewidth
  52.          1 1 1 1 setcmykcolor
  53.          0 0 3 0 360 arc fill
  54.          0 0 6 0 360 arc stroke
  55.          0 1 3 {
  56.             pop
  57.             90 rotate
  58.             0 0 0 0 setcmykcolor
  59.             0 0 moveto 3 0 lineto stroke
  60.             1 1 1 1 setcmykcolor
  61.             3 0 moveto 8 0 lineto stroke
  62.          } for
  63.       grestore
  64.    } {pop pop} ifelse
  65. } def
  66. %
  67. % DoLogo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  68. %                                                                            %
  69. % x_left y_upper  DoLogo  -                                                  %
  70. %                                                                            %
  71. % If /CompositorName is defined, then the logo will be placed in the crop    %
  72. % area. /JobDescription and /Contractor can also be defined in the TeX file  %
  73. % to define the job. If there is no definition, they simply will not show    %
  74. % up. Examples:                                                              %
  75. %   /CompositorName (Meridian Creative Group) def                            %
  76. %   /JobDescription (College Algebra: Concepts and Models 2/e) def           %
  77. %   /Contractor     (D.C. Heath and Company) def                             %
  78. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  79. /DoLogo
  80. {
  81.    moveto
  82.    save
  83.       %
  84.       % Variables to control the look of the Logo:
  85.       %
  86.       /LogoVgap 1 def              % Vertical gap between logo string and box
  87.       /LogoHgap 3 def              % Horizontal gap between logo string and box
  88.       /LogoFont {6 /Helvetica} def % The font to use for this logo.
  89.       %
  90.       % Gather some useful information about the Logo Font.
  91.       %
  92.       /LogoAscent LogoFont findfont /FontBBox get 3 get abs 1000 div mul def
  93.       /LogoDescent LogoFont findfont /FontBBox get 1 get abs 1000 div mul def
  94.       /LogoHeight LogoAscent LogoDescent add def
  95.       %
  96.       % <string> AddToLogo <string width>
  97.       %
  98.       /LogoWidth 0 def
  99.       /AddToLogo
  100.       {
  101.          dup show                         % leaving <string> on stack
  102.          stringwidth pop                  % <swidth> on stack
  103.       } def
  104.       %
  105.       % Start by setting line width, color, and establish logo font.
  106.       %
  107.       .24 setlinewidth
  108.       /TeXcolorcmyk where {pop 1 1 1 1 setcmykcolor} {0 setgray} ifelse
  109.       LogoFont findfont exch scalefont setfont
  110.       %
  111.       % Then move into position
  112.       %
  113.       LogoHgap LogoVgap LogoAscent add neg rmoveto
  114.       %
  115.       % If there is a logo, there will be a compositor, so start by setting
  116.       % the compositor name and add to the LogoWidth.
  117.       %
  118.       CompositorName AddToLogo          % Add compositor name to logo
  119.       LogoWidth add /LogoWidth exch def % Add compositor name to logo width
  120.       %
  121.       % If there is a job description, set it next.
  122.       %
  123.       /JobDescription where
  124.       {
  125.          pop                            % Get rid of dictionary
  126.          LogoFont pop 0 rmoveto         % Move a bit to the right
  127.          LogoWidth LogoFont pop add     % Add that on to the logo width
  128.          JobDescription AddToLogo       % Add job description to logo
  129.          add /LogoWidth exch def        % Add job description to logo width
  130.       } if
  131.       %
  132.       % Same thing with Contractor.
  133.       %
  134.       /Contractor where
  135.       {
  136.          pop                            % Get rid of dictionary
  137.          LogoFont pop 0 rmoveto         % Move a bit to the right
  138.          LogoWidth LogoFont pop add     % Add that on to the logo width
  139.          Contractor AddToLogo           % Add contractor to logo
  140.          add /LogoWidth exch def        % Add contractor to logo width
  141.       } if
  142.       %
  143.       % Add the gaps onto the logo dimensions for box drawing.
  144.       %
  145.       /LogoHeight LogoHeight 2 LogoVgap mul add def
  146.       /LogoWidth LogoWidth 2 LogoHgap mul add def
  147.       %
  148.       % Move into lower right corner of box and draw it clockwise.
  149.       %
  150.       LogoHgap LogoVgap LogoDescent add neg rmoveto
  151.       LogoWidth neg 0 rlineto 0 LogoHeight rlineto
  152.       LogoWidth 0 rlineto 0 LogoHeight neg rlineto stroke
  153.    restore
  154.    stroke
  155. } def
  156. %
  157. /DrawCenterTicks
  158. {
  159.    gsave
  160.       .3 setlinewidth
  161.       /TeXcolorcmyk where {pop 1 1 1 1 setcmykcolor} {0 setgray} ifelse
  162.       hsize cX 2 mul sub 2 div  cX 2 div neg  moveto
  163.          0  cX 2 div neg  rlineto
  164.       hsize cX 1.5 mul sub  vsize cX 2 mul sub 2 div  moveto
  165.          cX 2 div  0  rlineto
  166.       hsize cX 2 mul sub 2 div  vsize cX 1.5 mul sub  moveto
  167.          0  cX 2 div  rlineto
  168.       cX 2 div neg  vsize cX 2 mul sub 2 div  moveto
  169.          cX 2 div neg  0  rlineto
  170.       stroke
  171.    grestore
  172. } def
  173. %
  174. % NamePlates %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  175. % left bottom  NamePlates  -                                                %
  176. %                                                                           %
  177. % /FirstPlate, /SecondPlate, /ThirdPlate, and /FourthPlate have default     %
  178. % names but may be overridden in the job.hdr.                               %
  179. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  180. /NamePlates
  181. {
  182.       gsave
  183.          translate
  184.          % Make sure each plate has a name.
  185.          /FirstPlate  where {pop} {/FirstPlate  (Cyan)    def} ifelse
  186.          /SecondPlate where {pop} {/SecondPlate (Magenta) def} ifelse
  187.          /ThirdPlate  where {pop} {/ThirdPlate  (Yellow)  def} ifelse
  188.          /FourthPlate where {pop} {/FourthPlate (Black)   def} ifelse
  189.          /Helvetica-Bold findfont 10 scalefont setfont
  190.          % Cyan block
  191.          1 0 0 0 setcmykcolor
  192.          0 0 moveto
  193.          9 0 lineto
  194.          9 9 lineto
  195.          0 9 lineto
  196.          closepath
  197.          fill
  198.          0 0 0 0 setcmykcolor
  199.          0.75 1 moveto
  200.          (C) show
  201.          % Magenta block
  202.          0 1 0 0 setcmykcolor
  203.           9 0 moveto
  204.          18 0 lineto
  205.          18 9 lineto
  206.           9 9 lineto
  207.          closepath
  208.          fill
  209.          0 0 0 0 setcmykcolor
  210.          9.25 1 moveto
  211.          (M) show
  212.          % Yellow block
  213.          0 0 1 0 setcmykcolor
  214.          18 0 moveto
  215.          27 0 lineto
  216.          27 9 lineto
  217.          18 9 lineto
  218.          closepath
  219.          fill
  220.          0 0 0 0 setcmykcolor
  221.          19.25 1 moveto
  222.          (Y) show
  223.          % Black block
  224.          0 0 0 1 setcmykcolor
  225.          27 0 moveto
  226.          36 0 lineto
  227.          36 9 lineto
  228.          27 9 lineto
  229.          closepath
  230.          fill
  231.          0 0 0 0 setcmykcolor
  232.          27.5 1 moveto
  233.          (K) show
  234.          % Name Plates
  235.          /Helvetica-Narrow findfont 9 scalefont setfont
  236.          1 1 1 1 setcmykcolor
  237.          ( Plate:) show
  238.          1 0 0 0 setcmykcolor
  239.          FirstPlate  show
  240.          0 1 0 0 setcmykcolor
  241.          SecondPlate show
  242.          0 0 1 0 setcmykcolor
  243.          ThirdPlate  show
  244.          0 0 0 1 setcmykcolor
  245.          FourthPlate show
  246.       grestore
  247. } def
  248. %
  249. end %TeXDict
  250. %
  251. /bop-hook {
  252.    cX dup TR % move the origin a bit
  253.    gsave
  254.       % Draw center tic marks in the crop margin
  255.       DrawCenterTicks
  256.       % Do the logo
  257.       /CompositorName where {pop cX 2 div dup neg DoLogo} if
  258.       % Name the plates
  259.       /TeXcolorcmyk where {pop hsize 2 div cX add -18 NamePlates} if
  260.       % now draw four crop marks and four registration marks
  261.       0 0 0 CM cX -2 div dup RegMark
  262.       vsize cX 2 mul sub dup
  263.       hsize cX 2 mul sub dup
  264.       isls { 4 2 roll } if
  265.       0 2 copy 90 CM cX 2 div sub exch cX 2 div add exch RegMark
  266.       exch 2 copy 180 CM cX 2 div add exch cX 2 div add exch RegMark
  267.       0 exch 2 copy 270 CM cX 2 div add exch cX 2 div sub exch RegMark
  268.    grestore
  269.    0 cX -2 mul TR % now move to where we start drawing
  270.    isls { cX -2 mul 0 TR } if
  271. } def
  272.