3 % Copyright (c) 1995-1998 Markku Rossi.
5 % Author: Markku Rossi <mtr@iki.fi>
8 % This file is part of GNU enscript.
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)
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.
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 % the Free Software Foundation, 51 Franklin Street, Fifth Floor,
23 % Boston, MA 02110-1301, USA.
26 % -- code follows this line --
31 /_S { % save current state
34 /_R { % restore from saved state
38 /S { % showpage protecting gstate
44 /MF { % fontname newfontname -> - make a new encoded font
48 /fontdict fontname findfont def
49 /newfont fontdict maxlength dict def
57 % copy to the new font dictionary
58 exch newfont 3 1 roll put
62 newfont /FontName newfontname put
64 % insert only valid encoding vectors
65 encoding_vector length 256 eq {
66 newfont /Encoding encoding_vector put
69 newfontname newfont definefont pop
72 /MF_PS { % fontname newfontname -> - make a new font preserving its enc
76 /fontdict fontname findfont def
77 /newfont fontdict maxlength dict def
85 % copy to the new font dictionary
86 exch newfont 3 1 roll put
90 newfont /FontName newfontname put
92 newfontname newfont definefont pop
95 /SF { % fontname width height -> - set a new font
100 [width 0 0 height 0 0] makefont setfont
103 /SUF { % fontname width height -> - set a new user font
108 /F-gs-user-font width height SF
111 /SUF_PS { % fontname width height -> - set a new user font preserving its enc
115 /F-gs-user-font MF_PS
116 /F-gs-user-font width height SF
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
131 /bgs { % x y height blskip gray str -> - show string with bg color
140 x y blskip sub str stringwidth pop height Box
147 /bgcs { % x y height blskip red green blue str -> - show string with bg color
158 x y blskip sub str stringwidth pop height Box
159 red green blue setrgbcolor
166 /highlight_bars { % nlines lineheight output_y_margin gray -> -
173 % This 2 is just a magic number to sync highlight lines to text.
174 0 d_header_y ymarg sub 2 sub translate
176 /cw d_output_w cols div def
177 /nrows d_output_h ymarg 2 mul sub lineheight div cvi 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
197 % Line highlight bar.
198 /line_highlight { % x y width height gray -> -
201 Box gray setgray fill
205 % Column separator lines.
209 0 d_footer_h translate
210 /cw d_output_w cols div def
213 0 d_output_h rlineto stroke
225 0 d_output_h neg rlineto
230 % Do the actual underlay drawing
233 ul_str true charpath stroke
243 d_page_h neg d_page_w atan rotate
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
253 /user_underlay { % - -> -
259 0 0 ul_h_ptsize 2 div sub moveto
265 /page_prefeed { % bool -> -
266 statusdict /prefeed known {
267 statusdict exch /prefeed exch put
273 % Wrapped line markers
274 /wrapped_line_mark { % x y charwith charheight type -> -
282 % Black boxes (like TeX does)
286 0 h rlineto w 2 div 0 rlineto 0 h neg rlineto
294 x w 2 div add y h 2 div add M
296 x w 4 div add y lineto stroke
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
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
316 0 setgray 0 setlinecap
317 1 setlinewidth 0 setlinejoin
318 10 setmiterlimit [ ] 0 setdash newpath
319 /languagelevel where {
322 false setstrokeadjust false setoverprint
328 count op_count sub { pos } repeat % Clean up stacks
329 countdictstack dict_count sub { end } repeat
333 % Check PostScript language level.
334 /languagelevel where {
335 pop /gs_languagelevel languagelevel def
337 /gs_languagelevel 1 def