source: trunk/third/enscript/lib/enscript.pro @ 17620

Revision 17620, 5.9 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r17619, which included commits to RCS files with non-trunk default branches.
Line 
1%
2% PostScript prolog.
3% Copyright (c) 1995, 1996, 1997 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% 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
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  % 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/SF { % fontname width height -> -      set a new font
73  /height exch def
74  /width exch def
75
76  findfont
77  [width 0 0 height 0 0] makefont setfont
78} def
79
80/SUF { % fontname width height -> -     set a new user font
81  /height exch def
82  /width exch def
83
84  /F-gs-user-font MF
85  /F-gs-user-font width height SF
86} def
87
88/M {moveto} bind def
89/s {show} bind def
90
91/Box {  % x y w h -> -                  define box path
92  /d_h exch def /d_w exch def /d_y exch def /d_x exch def
93  d_x d_y  moveto
94  d_w 0 rlineto
95  0 d_h rlineto
96  d_w neg 0 rlineto
97  closepath
98} def
99
100/bgs {  % x y height blskip gray str -> -       show string with bg color
101  /str exch def
102  /gray exch def
103  /blskip exch def
104  /height exch def
105  /y exch def
106  /x exch def
107
108  gsave
109    x y blskip sub str stringwidth pop height Box
110    gray setgray
111    fill
112  grestore
113  x y M str s
114} def
115
116% Highlight bars.
117/highlight_bars {       % nlines lineheight output_y_margin gray -> -
118  gsave
119    setgray
120    /ymarg exch def
121    /lineheight exch def
122    /nlines exch def
123
124    % This 2 is just a magic number to sync highlight lines to text.
125    0 d_header_y ymarg sub 2 sub translate
126
127    /cw d_output_w cols div def
128    /nrows d_output_h ymarg 2 mul sub lineheight div cvi def
129
130    % for each column
131    0 1 cols 1 sub {
132      cw mul /xp exch def
133
134      % for each rows
135      0 1 nrows 1 sub {
136        /rn exch def
137        rn lineheight mul neg /yp exch def
138        rn nlines idiv 2 mod 0 eq {
139          % Draw highlight bar.  4 is just a magic indentation.
140          xp 4 add yp cw 8 sub lineheight neg Box fill
141        } if
142      } for
143    } for
144
145  grestore
146} def
147
148% Line highlight bar.
149/line_highlight {       % x y width height gray -> -
150  gsave
151    /gray exch def
152    Box gray setgray fill
153  grestore
154} def
155
156% Column separator lines.
157/column_lines {
158  gsave
159    .1 setlinewidth
160    0 d_footer_h translate
161    /cw d_output_w cols div def
162    1 1 cols 1 sub {
163      cw mul 0 moveto
164      0 d_output_h rlineto stroke
165    } for
166  grestore
167} def
168
169% Column borders.
170/column_borders {
171  gsave
172    .1 setlinewidth
173    0 d_footer_h moveto
174    0 d_output_h rlineto
175    d_output_w 0 rlineto
176    0 d_output_h neg rlineto
177    closepath stroke
178  grestore
179} def
180
181% Do the actual underlay drawing
182/draw_underlay {
183  ul_style 0 eq {
184    ul_str true charpath stroke
185  } {
186    ul_str show
187  } ifelse
188} def
189
190% Underlay
191/underlay {     % - -> -
192  gsave
193    0 d_page_h translate
194    d_page_h neg d_page_w atan rotate
195
196    ul_gray setgray
197    ul_font setfont
198    /dw d_page_h dup mul d_page_w dup mul add sqrt def
199    ul_str stringwidth pop dw exch sub 2 div ul_h_ptsize -2 div moveto
200    draw_underlay
201  grestore
202} def
203
204/user_underlay {        % - -> -
205  gsave
206    ul_x ul_y translate
207    ul_angle rotate
208    ul_gray setgray
209    ul_font setfont
210    0 0 ul_h_ptsize 2 div sub moveto
211    draw_underlay
212  grestore
213} def
214
215% Page prefeed
216/page_prefeed {         % bool -> -
217  statusdict /prefeed known {
218    statusdict exch /prefeed exch put
219  } {
220    pop
221  } ifelse
222} def
223
224% Wrapped line markers
225/wrapped_line_mark {    % x y charwith charheight type -> -
226  /type exch def
227  /h exch def
228  /w exch def
229  /y exch def
230  /x exch def
231
232  type 2 eq {
233    % Black boxes (like TeX does)
234    gsave
235      0 setlinewidth
236      x w 4 div add y M
237      0 h rlineto w 2 div 0 rlineto 0 h neg rlineto
238      closepath fill
239    grestore
240  } {
241    type 3 eq {
242      % Small arrows
243      gsave
244        .2 setlinewidth
245        x w 2 div add y h 2 div add M
246        w 4 div 0 rlineto
247        x w 4 div add y lineto stroke
248
249        x w 4 div add w 8 div add y h 4 div add M
250        x w 4 div add y lineto
251        w 4 div h 8 div rlineto stroke
252      grestore
253    } {
254      % do nothing
255    } ifelse
256  } ifelse
257} def
258
259% EPSF import.
260
261/BeginEPSF {
262  /b4_Inc_state save def                % Save state for cleanup
263  /dict_count countdictstack def        % Count objects on dict stack
264  /op_count count 1 sub def             % Count objects on operand stack
265  userdict begin
266  /showpage { } def
267  0 setgray 0 setlinecap
268  1 setlinewidth 0 setlinejoin
269  10 setmiterlimit [ ] 0 setdash newpath
270  /languagelevel where {
271    pop languagelevel
272    1 ne {
273      false setstrokeadjust false setoverprint
274    } if
275  } if
276} bind def
277
278/EndEPSF {
279  count op_count sub { pos } repeat     % Clean up stacks
280  countdictstack dict_count sub { end } repeat
281  b4_Inc_state restore
282} bind def
283
284% Check PostScript language level.
285/languagelevel where {
286  pop /gs_languagelevel languagelevel def
287} {
288  /gs_languagelevel 1 def
289} ifelse
Note: See TracBrowser for help on using the repository browser.