(file) Return to enscript.pro CVS log (file) (dir) Up to [RizwankCVS] / testProject / lib

  1 rizwank 1.1 %
  2             % PostScript prolog.
  3             % Copyright (c) 1995-1998 Markku Rossi.
  4             %
  5             % Author: Markku Rossi <mtr@iki.fi>
  6             %
  7             %
  8             % This file is part of GNU enscript.
  9             %
 10             % This program is free software; you can redistribute it and/or modify
 11             % it under the terms of the GNU General Public License as published by
 12             % the Free Software Foundation; either version 2, or (at your option)
 13             % any later version.
 14             %
 15             % This program is distributed in the hope that it will be useful,
 16             % but WITHOUT ANY WARRANTY; without even the implied warranty of
 17             % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 18             % GNU General Public License for more details.
 19             %
 20             % You should have received a copy of the GNU General Public License
 21             % along with this program; see the file COPYING.  If not, write to
 22 rizwank 1.1 % the Free Software Foundation, 59 Temple Place - Suite 330,
 23             % Boston, MA 02111-1307, USA.
 24             %
 25             
 26             % -- code follows this line --
 27             %
 28             % Procedures.
 29             %
 30             
 31             /_S {	% save current state
 32               /_s save def
 33             } def
 34             /_R {	% restore from saved state
 35               _s restore
 36             } def
 37             
 38             /S {	% showpage protecting gstate
 39               gsave
 40               showpage
 41               grestore
 42             } bind def
 43 rizwank 1.1 
 44             /MF {	% fontname newfontname -> -	make a new encoded font
 45               /newfontname exch def
 46               /fontname exch def
 47             
 48               /fontdict fontname findfont def
 49               /newfont fontdict maxlength dict def
 50             
 51               fontdict {
 52                 exch
 53                 dup /FID eq {
 54                   % skip FID pair
 55                   pop pop
 56                 } {
 57                   % copy to the new font dictionary
 58                   exch newfont 3 1 roll put
 59                 } ifelse
 60               } forall
 61             
 62               newfont /FontName newfontname put
 63             
 64 rizwank 1.1   % insert only valid encoding vectors
 65               encoding_vector length 256 eq {
 66                 newfont /Encoding encoding_vector put
 67               } if
 68             
 69               newfontname newfont definefont pop
 70             } def
 71             
 72             /MF_PS { % fontname newfontname -> -	make a new font preserving its enc
 73               /newfontname exch def
 74               /fontname exch def
 75             
 76               /fontdict fontname findfont def
 77               /newfont fontdict maxlength dict def
 78             
 79               fontdict {
 80                 exch
 81                 dup /FID eq {
 82                   % skip FID pair
 83                   pop pop
 84                 } {
 85 rizwank 1.1       % copy to the new font dictionary
 86                   exch newfont 3 1 roll put
 87                 } ifelse
 88               } forall
 89             
 90               newfont /FontName newfontname put
 91             
 92               newfontname newfont definefont pop
 93             } def
 94             
 95             /SF { % fontname width height -> -	set a new font
 96               /height exch def
 97               /width exch def
 98             
 99               findfont
100               [width 0 0 height 0 0] makefont setfont
101             } def
102             
103             /SUF { % fontname width height -> -	set a new user font
104               /height exch def
105               /width exch def
106 rizwank 1.1 
107               /F-gs-user-font MF
108               /F-gs-user-font width height SF
109             } def
110             
111             /SUF_PS { % fontname width height -> -	set a new user font preserving its enc
112               /height exch def
113               /width exch def
114             
115               /F-gs-user-font MF_PS
116               /F-gs-user-font width height SF
117             } def
118             
119             /M {moveto} bind def
120             /s {show} bind def
121             
122             /Box {	% x y w h -> -			define box path
123               /d_h exch def /d_w exch def /d_y exch def /d_x exch def
124               d_x d_y  moveto
125               d_w 0 rlineto
126               0 d_h rlineto
127 rizwank 1.1   d_w neg 0 rlineto
128               closepath
129             } def
130             
131             /bgs {	% x y height blskip gray str -> -	show string with bg color
132               /str exch def
133               /gray exch def
134               /blskip exch def
135               /height exch def
136               /y exch def
137               /x exch def
138             
139               gsave
140                 x y blskip sub str stringwidth pop height Box
141                 gray setgray
142                 fill
143               grestore
144               x y M str s
145             } def
146             
147             /bgcs { % x y height blskip red green blue str -> -  show string with bg color
148 rizwank 1.1   /str exch def
149               /blue exch def
150               /green exch def
151               /red exch def
152               /blskip exch def
153               /height exch def
154               /y exch def
155               /x exch def
156             
157               gsave
158                 x y blskip sub str stringwidth pop height Box
159                 red green blue setrgbcolor
160                 fill
161               grestore
162               x y M str s
163             } def
164             
165             % Highlight bars.
166             /highlight_bars {	% nlines lineheight output_y_margin gray -> -
167               gsave
168                 setgray
169 rizwank 1.1     /ymarg exch def
170                 /lineheight exch def
171                 /nlines exch def
172             
173                 % This 2 is just a magic number to sync highlight lines to text.
174                 0 d_header_y ymarg sub 2 sub translate
175             
176                 /cw d_output_w cols div def
177                 /nrows d_output_h ymarg 2 mul sub lineheight div cvi def
178             
179                 % for each column
180                 0 1 cols 1 sub {
181                   cw mul /xp exch def
182             
183                   % for each rows
184                   0 1 nrows 1 sub {
185                     /rn exch def
186                     rn lineheight mul neg /yp exch def
187                     rn nlines idiv 2 mod 0 eq {
188             	  % Draw highlight bar.  4 is just a magic indentation.
189             	  xp 4 add yp cw 8 sub lineheight neg Box fill
190 rizwank 1.1 	} if
191                   } for
192                 } for
193             
194               grestore
195             } def
196             
197             % Line highlight bar.
198             /line_highlight {	% x y width height gray -> -
199               gsave
200                 /gray exch def
201                 Box gray setgray fill
202               grestore
203             } def
204             
205             % Column separator lines.
206             /column_lines {
207               gsave
208                 .1 setlinewidth
209                 0 d_footer_h translate
210                 /cw d_output_w cols div def
211 rizwank 1.1     1 1 cols 1 sub {
212                   cw mul 0 moveto
213                   0 d_output_h rlineto stroke
214                 } for
215               grestore
216             } def
217             
218             % Column borders.
219             /column_borders {
220               gsave
221                 .1 setlinewidth
222                 0 d_footer_h moveto
223                 0 d_output_h rlineto
224                 d_output_w 0 rlineto
225                 0 d_output_h neg rlineto
226                 closepath stroke
227               grestore
228             } def
229             
230             % Do the actual underlay drawing
231             /draw_underlay {
232 rizwank 1.1   ul_style 0 eq {
233                 ul_str true charpath stroke
234               } {
235                 ul_str show
236               } ifelse
237             } def
238             
239             % Underlay
240             /underlay {	% - -> -
241               gsave
242                 0 d_page_h translate
243                 d_page_h neg d_page_w atan rotate
244             
245                 ul_gray setgray
246                 ul_font setfont
247                 /dw d_page_h dup mul d_page_w dup mul add sqrt def
248                 ul_str stringwidth pop dw exch sub 2 div ul_h_ptsize -2 div moveto
249                 draw_underlay
250               grestore
251             } def
252             
253 rizwank 1.1 /user_underlay {	% - -> -
254               gsave
255                 ul_x ul_y translate
256                 ul_angle rotate
257                 ul_gray setgray
258                 ul_font setfont
259                 0 0 ul_h_ptsize 2 div sub moveto
260                 draw_underlay
261               grestore
262             } def
263             
264             % Page prefeed
265             /page_prefeed {		% bool -> -
266               statusdict /prefeed known {
267                 statusdict exch /prefeed exch put
268               } {
269                 pop
270               } ifelse
271             } def
272             
273             % Wrapped line markers
274 rizwank 1.1 /wrapped_line_mark {	% x y charwith charheight type -> -
275               /type exch def
276               /h exch def
277               /w exch def
278               /y exch def
279               /x exch def
280             
281               type 2 eq {
282                 % Black boxes (like TeX does)
283                 gsave
284                   0 setlinewidth
285                   x w 4 div add y M
286                   0 h rlineto w 2 div 0 rlineto 0 h neg rlineto
287                   closepath fill
288                 grestore
289               } {
290                 type 3 eq {
291                   % Small arrows
292                   gsave
293                     .2 setlinewidth
294                     x w 2 div add y h 2 div add M
295 rizwank 1.1         w 4 div 0 rlineto
296                     x w 4 div add y lineto stroke
297             
298                     x w 4 div add w 8 div add y h 4 div add M
299                     x w 4 div add y lineto
300             	w 4 div h 8 div rlineto stroke
301                   grestore
302                 } {
303                   % do nothing
304                 } ifelse
305               } ifelse
306             } def
307             
308             % EPSF import.
309             
310             /BeginEPSF {
311               /b4_Inc_state save def    		% Save state for cleanup
312               /dict_count countdictstack def	% Count objects on dict stack
313               /op_count count 1 sub def		% Count objects on operand stack
314               userdict begin
315               /showpage { } def
316 rizwank 1.1   0 setgray 0 setlinecap
317               1 setlinewidth 0 setlinejoin
318               10 setmiterlimit [ ] 0 setdash newpath
319               /languagelevel where {
320                 pop languagelevel
321                 1 ne {
322                   false setstrokeadjust false setoverprint
323                 } if
324               } if
325             } bind def
326             
327             /EndEPSF {
328               count op_count sub { pos } repeat	% Clean up stacks
329               countdictstack dict_count sub { end } repeat
330               b4_Inc_state restore
331             } bind def
332             
333             % Check PostScript language level.
334             /languagelevel where {
335               pop /gs_languagelevel languagelevel def
336             } {
337 rizwank 1.1   /gs_languagelevel 1 def
338             } ifelse

Rizwan Kassim
Powered by
ViewCVS 0.9.2