%
% NPR prologue
% Written (w) 1988 by Stefan Stapelberg
% @(#)npr.prologue	1.2 (Mikros) 88/08/16
%

% Font definitions you may want to change.
% Note: if you change the point size of a font,
%       you should change vertical spacing also
%
/Logofont /Bookman-DemiItalic findfont def		% for Logo, not scaled
/Headfont /Bookman-Demi findfont 11 scalefont def	% for From:-Header etc.
/Linefont /Bookman-Light findfont 11 scalefont def	% for From:-Lines etc.
/Textfont /Courier findfont 10 scalefont def		% normal text font

% vertical spacing
%
/nldist 11 def		% text newline distance
/hldist 12 def		% header newline distance

% don't bother for the rest, things
% should already working perfectly
%
/tident 10 def		% text indent
/hident 10 def		% header ident (internal only)
/nstr 5 string def	% string storage
/inch { 72 mul } def	% convert inch to point

/DrawBox		% stack: boundary box x1,y1 x2,y2
 { /radius 10 def
   radius sub /uborder exch def		% upper border
   radius sub /rborder exch def		% right border
   radius add /dborder exch def		% lower border
   radius add /lborder exch def		% left border

   newpath
     lborder radius sub uborder moveto	% draw box
     lborder dborder radius 180 270 arc
     rborder dborder radius 270 0 arc
     rborder uborder radius 0 90 arc
     lborder uborder radius 90 180 arc
   closepath
 } def

/Logo0			% print nice logo, version 1
 { gsave
     Logofont 28 scalefont setfont
     (NetNEWS) dup /Title exch def		% logo string
       stringwidth pop /Titlelen exch def	% length of string

     RM 2.5 inch sub TM 0.5 inch sub translate
     0 0 2.5 inch 0.5 inch DrawBox
     1.5 setlinewidth stroke

     newpath					% set clipping path
       2.5 inch Titlelen sub 2 div 9 translate
       0 0 moveto Title true
     charpath clip

     newpath					% draw rays
       Titlelen 2 div -7 translate
       0.25 setlinewidth
       0 1.5 179
       { gsave
           rotate
           0 0 moveto 108 0 lineto stroke
         grestore
       }for

   grestore
 } def

/Logo1			% print logo, version 2
 { gsave
     RM 2.5 inch sub TM 0.5 inch sub translate
     0 0 2.5 inch 0.5 inch DrawBox clip	% set clip path

     Logofont 9 scalefont setfont	% print background
     newpath
       0 0.5 inch 7 sub moveto
       (NEWS ) /Title exch def
       0.5 setgray
       { { pop pop currentpoint pop 2.5 inch gt
	   { currentpoint 9 sub exch pop 0 exch moveto } if } Title kshow
           currentpoint exch pop -0 lt { exit } if
       } loop

     Logofont 28 scalefont setfont	% print logo over background
     newpath
       (NetNEWS) dup stringwidth pop
       2.5 inch exch sub 2 div 9 moveto
       0 setgray show

   grestore
 } def

/Logo2			% print logo, version 3
 { gsave
     Logofont 28 scalefont setfont
     (NetNEWS) dup /Title exch def		% logo string
       stringwidth pop /Titlelen exch def	% length of string

     RM 2.5 inch sub TM 0.5 inch sub translate
     0 0 2.5 inch 0.5 inch DrawBox
     1.5 setlinewidth stroke

     newpath
       2.5 inch Titlelen sub 2 div 5 add 3 translate
       .95 -.05 0 { setgray 0 0 moveto Title show -1 .5 translate } for
       1 setgray 0 0 moveto Title show

   grestore
 } def

/Logo3			% print logo, version 4
 { gsave
     Logofont 28 scalefont setfont
     (NetNEWS) dup /Title exch def		% logo string
       stringwidth pop /Titlelen exch def	% length of string

     RM 2.5 inch sub TM 0.5 inch sub translate
     0 0 2.5 inch 0.5 inch DrawBox
     0 setgray fill

     newpath					% set clipping path
     (NetNEWS) dup stringwidth pop
       2.5 inch exch sub 2 div 0 translate
       1 setgray 1 1.5 scale 0 -1 moveto show

   grestore
 } def

/Logo4			% print logo, version 5
 { gsave
     RM 2.5 inch sub TM 0.5 inch sub translate
     0 0 2.5 inch 0.5 inch DrawBox
     1.5 setlinewidth stroke

     Logofont 28 scalefont setfont
     newpath
       (NetNEWS) dup stringwidth pop
       2.5 inch exch sub 2 div 9 moveto
       true charpath 0.5 setlinewidth stroke

   grestore
 } def


/PrintHeadline		% print header line at top of each page
 { 1 page eq			% this is first page,
   { PrintLogo cvx exec		% so draw a logo on it
     LM TM 0.5 inch sub		% prepare clipping path
     RM 2.5 inch sub 9 sub TM }	% for rest of header
   { LM TM 0.5 inch sub RM TM } ifelse

   DrawBox
   gsave 0.8 setgray fill grestore
   gsave 1.5 setlinewidth stroke grestore
   gsave clip
     Headfont setfont
     LM tident add TM 28 sub translate
     newpath
       0 0 moveto Subline show
       0 12 moveto Headline show
     RM LM sub tident 2 mul sub
     (Page 999) stringwidth pop sub 12 moveto
     (Page ) show page nstr cvs show
   grestore
 } def

/InitPage		% stack: pageno
 { /page exch def
   /ypos TM 0.625 inch sub def
   PrintHeadline
   Textfont setfont
 } def

/PrintPage
 { showpage
   page 1 add InitPage
   2 Newline
 } def

/Newline		% stack: number of newlines
 { nldist mul ypos exch sub /ypos exch def
   LM tident add ypos moveto
   ypos BM lt { PrintPage } if
 } def

/Nextline
 { hldist ypos exch sub /ypos exch def
   LM hident add ypos moveto
 } def

/PrintField		% stack: [(Headerstring) (Fieldstring)]
 { aload pop exch
   /hident tident def
   Nextline Headfont setfont
   dup stringwidth pop tident add /hident exch def show
   Linefont setfont
   { pop pop currentpoint pop RM tident 2 mul sub ge { Nextline } if } exch kshow
 } def

/PrintHeader		% print header array on title page
 { gsave
     HeaderList { PrintField } forall
     /ypos ypos 9 sub def
     LM ypos RM TM 0.6 inch sub DrawBox stroke
   grestore
   2 Newline
 } def

/PrintText		% print text, take care of line wrap
 {
   { pop pop currentpoint pop RM tident sub ge { 1 Newline } if } exch kshow
 } def

/EndText		% ouput last page
 { showpage
 } def