2 % Redefiniton of the PostScript file output operators so results go to paper.
3 % Complicated and slow, but the implementation doesn't place many demands on
4 % included PostScript. About all that's required is gentle treatment of the
5 % graphics state between write calls.
22 /pagebbox [0 0 612 792] def
25 /min {2 copy gt {exch} if pop} def
28 landscape {/orientation 90 orientation add def} if
29 font findfont 1 1.1 div scalefont setfont
32 xcenter ycenter translate
33 orientation rotation mul rotate
34 width 2 div neg height 2 div translate
35 xoffset inch yoffset inch neg translate
36 pointsize 1.1 mul dup scale
37 magnification dup aspectratio mul scale
38 height width div 1 min dup scale
45 /pagebbox [clippath pathbbox newpath] def
46 roundpage currentdict /roundpagebbox known and {roundpagebbox} if
49 4 -1 roll exch 4 1 roll 4 copy
50 landscape {4 2 roll} if
53 add 2 div /xcenter exch def
54 add 2 div /ycenter exch def
58 % Unbind the operators in an executable array or packedarray. Leaves the
59 % unbound array or the original object on the stack.
64 1 index type /arraytype eq
65 2 index type /packedarraytype eq or and {
66 dup length array copy cvx
68 dup type /operatortype eq {
72 dup type /dicttype eq {
73 dup maxlength dict exch {
80 1 index type /arraytype eq
81 2 index type /packedarraytype eq or and {
93 % New write operator - don't bind the definition! Expands tabs and backspaces,
94 % wraps long lines, and starts a new page whenever necessary. The code that
95 % handles newlines assumes lines are separated by one vertical unit.
103 ( ) stringwidth pop neg 0 rmoveto
104 currentpoint pop 0 lt {
105 currentpoint exch pop 0 exch moveto
112 currentpoint pop ( ) stringwidth pop div round cvi
121 currentpoint 0 exch 1 sub moveto pop
123 gsave clippath pathbbox pop pop exch pop grestore
124 currentpoint exch pop 1 sub ge {
132 gsave showpage grestore
139 currentpoint 0 exch moveto pop
145 currentpoint 0 ne exch 0 ne or {
154 gsave clippath pathbbox pop 3 1 roll pop pop grestore
155 ( ) stringwidth pop currentpoint pop add le {
158 ( ) dup 0 4 -1 roll put show
162 pop % and file object
166 % All the other file output operators call our redefined write operator.
170 (%stdout) (w) file exch {1 index exch write} forall
175 {1 index exch write} forall
180 (0123456789ABCDEF) 3 1 roll {
182 3 index exch -4 bitshift 16#F and get 2 index exch write
183 2 index exch 16#F and get 1 index exch write
189 % Unbind and redefine the remaining file output procedures.
192 /= dup load Unbind def
193 /== dup load Unbind def
194 /stack dup load Unbind def
195 /pstack dup load Unbind def