File: dvi2.psdoc

package info (click to toggle)
dvi2ps 4.1j-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,740 kB
  • ctags: 2,295
  • sloc: ansic: 14,953; sh: 964; makefile: 284
file content (388 lines) | stat: -rw-r--r-- 11,546 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
%
% for use by dvi2ps j-version
%
% a start (Ha!) at a TeX mode for PostScript.
% The following defines procedures assumed and used by program "dvi2ps"
% and must be downloaded or sent as a header file for all TeX jobs.
%
% Original author: 
%      Neal Holtz, Carleton University, Ottawa, Canada
%      <holtz@cascade.carleton.cdn>
%      <holtz%cascade.carleton.cdn@relay.cs.net>
%      June, 1985   Last Modified: Aug 25/85
%
% PostScript illustration support:
%      Jean-Francois Lamy, AI group, University of Toronto, Canada
%      lamy@ai.toronto.edu, lamy@ai.toronto.cdn
%
% $Log:	tex.ps,v $
% Revision 1.5  86/11/27  10:30:54  lamy
% Mixing Mac and other PostScript illustrations now possible.
% vsize positive now means "above current point".
% 
% Revision 1.4  86/10/30  12:43:24  lamy
% Now uses the rotate operator for landscape and envelope modes.
% Used to be convoluted, non portable code to avoid round-off errors
% that do not seem to be present on any of our printers.
% 
% Revision 1.3  86/10/30  12:27:50  lamy
% Fixed bug in @bop1 that caused top lines to be clipped when using proc.sty
%
% 86-07-17 jfl
%   Added envelope keyword definition.  Same as landscape but positioned
%   so that an envelope inserted upside down is printed correctly
%   This reduces the occurence of paper jams.
%
% 86-06-23  JF Lamy, U. of Toronto <lamy@ai.toronto.edu, lamy@utai.uucp>
%   Updated to support the Macintosh LaserWriter driver version 3.x
%   instead of 1.1.  Added rotation of illustrations.
% 
% oystr 12-Feb-1986
%   Changed @dc macro to check for badly formed bits in character
%   definitions.  Can get a <> bit map if a character is not actually
%   in the font file.  This is absolutely guaranteed to drive the
%   printer nuts - it will appear that you can no longer define a
%   new font, although the built-ins will still be there.
%
% 89-05-22 Kazuhiro Kazama (kazama@expert-sun.ntt.jp)
%   Various paper type added.
%   Bug fix in @MacSetUp.
%   Now use the eepic.
%   "BoundingBox" information is available.

% To convert this file into a downloaded file instead of a header
% file, uncomment all of the lines beginning with %-%
%-%0000000 			% Server loop exit password
%-%serverdict begin exitserver
%-%  systemdict /statusdict known
%-%  {statusdict begin 9 0 3 setsccinteractive /waittimeout 300 def end}
%-% if

% If the packed-array facility is available, this program sets the
% array-packing mode.
%systemdict /setpacking known {
%    /savepacking currentpacking def
%    true setpacking
%} if

/TeXDict 300 dict def	% define a working dictionary
TeXDict begin		% start using it.

/inch {72 mul} bind def	% converts inches to default internal units

%%%%%%%%%%%%%%%%%%%%% Page setup (user) options %%%%%%%%%%%%%%%%%%%%%%%%
% dvi2ps will output coordinates in the TeX system ([0,0] 1" down and in
% from top left, with y +ive downward).  The default PostScript system
% is [0,0] at bottom left, y +ive up.  The Many Matrix Machinations in
% the following code are an attempt to reconcile that. The intent is to
% specify the scaling as 1 and have only translations in the matrix to
% properly position the text.  Caution: the default device matrices are
% *not* the same in all PostScript devices; that should not matter in most 
% of the code below (except for lanscape mode -- in that, rotations of
% -90 degrees resulted in the the rotation matrix [ e 1 ]
%                                                 [ 1 e ]
% where the "e"s were almost exactly but not quite zeros.
%
/largepaperarray [
    /letter /legal /11x17
    /b4 /b5 /a5 /a4 /a3
] def
/smallpaperarray [
    /note dup where {
	pop
    }{
	pop /lettersmall dup where {
	    pop
	}{
	    pop /letter
	} ifelse
    } ifelse
    /legal /11x17
    /b4 /b5 /a5
    /a4small dup where {
	pop
    }{
	pop /note dup where {
	    pop
	}{
	    pop /a4
	} ifelse
    } ifelse
    /a3
] def
/setpaper {
    papertray {
	dup where {
	    exch get exec
	}{
	    pop
	} ifelse
    }{
	pop
    } ifelse
} bind def

/trayarray [
    /lettertray /legaltray /11x17tray
    /b4tray /b5tray /a5tray /a4tray /a3tray
] def
/settray {
    dup statusdict exch known manualfeed not and {
	mark exch statusdict begin load
	{
	    exec
	} stopped {
	    $error /newerror get {
		$error /errorname get /rangecheck eq {
		    (Tray not found, using default tray.\n) print flush
		    TeXDict /papertray false put
		}{
		    handleerror
		} ifelse
		$error /newerror false put
	    } if
	} if
	end cleartomark
    }{
	pop
    } ifelse
} bind def

/papertray true def
/widtharray  [	% paper width
    8.5 inch 8.5 inch 11 inch
    10.12 inch 7.17 inch
    5.83 inch 8.27 inch 11.69 inch
] def
/heightarray [	% paper height
    11 inch 14 inch 17 inch
    14.33 inch 10.12 inch
    8.27 inch 11.69 inch 16.54 inch
] def
/xoffset 0 def	% initial offset value of x-axis
/yoffset 0 def	% initial offset value of y-axis
% ##XCOORD## and ##YCOORD## will be replaced
% by 72=1 inch (or site-dependent value) upon installation
/leftm ##XCOORD## def	% left margin
/topm ##YCOORD## def	% top margin
/landscape false def
/manualfeed false def
/sizesetup {  % papertype sizesetup -
    dup widtharray exch get /paperwidth exch def
    heightarray exch get /paperheight exch def
} bind def
/pagesetup {  % papertype pagesetup -
    dup sizesetup
    dup trayarray exch get settray
    large {largepaperarray}{smallpaperarray} ifelse
    exch get setpaper
} bind def
/@lettersize {0 sizesetup} def
/@legalsize {1 sizesetup} def
/@tabloidsize {2 sizesetup} def
/@b4size {3 sizesetup} def
/@b5size {4 sizesetup} def
/@a5size {5 sizesetup} def
/@a4size {6 sizesetup} def
/@a3size {7 sizesetup} def
/@letter {0 pagesetup} def
/@legal {1 pagesetup} def
/@tabloid {2 pagesetup} def
/@b4 {3 pagesetup} def
/@b5 {4 pagesetup} def
/@a5 {5 pagesetup} def
/@a4 {6 pagesetup} def
/@a3 {7 pagesetup} def
/@landscape {/landscape true def} bind def
/@manualfeed {
    /manualfeed true def
    statusdict /manualfeed known {
	statusdict /manualfeed true put
	statusdict /manualfeedtimeout 120 put	% default value = 60
    } if
} bind def
/@large {/large true def} bind def
/@small {/large false def} bind def
/@envelope {
    % I don't know if the following coordinates are appropriate.
    % I just fixed it to be resolution-independent. (T. Sakurai)
    /xoffset 4.28 inch def
    /yoffset 1.5 inch def
    @letter
} bind def
/COPIES {	% n COPIES -   set number of copies
    /#copies exch def
} bind def

%%%%%%%%%%%%%%%%%%%% Procedure Defintions %%%%%%%%%%%%%%%%%%%%%%%%%%

/NF {	% corr size id NF -	-- initialize a new font dictionary
    /newname exch def
    /fsize exch def
    /corr exch def
    newname 7 dict def	% allocate new font dictionary
    newname load begin
	/FontType 3 def
	/FontMatrix [corr 0 0 corr neg 0 0] def
	/FontBBox [0 0 1 1] def
	/BitMaps fsize array def
	/BuildChar /CharBuilder load def
	/Encoding 256 array def
	0 1 255 {Encoding exch /.notdef put} for
    end
    newname newname load definefont pop
} bind def

% the following is the only character builder we need.  it looks up the
% char data in the BitMaps array, and paints the character if possible.
% char data  -- a bitmap descriptor -- is an array of length 6, of
%          which the various slots are:

/ch-image {ch-data 0 get} bind def	% the hex string image
/ch-width {ch-data 1 get} bind def	% the number of pixels across
/ch-height {ch-data 2 get} bind def	% the number of pixels tall
/ch-xoff {ch-data 3 get} bind def	% number of pixels below origin
/ch-yoff {ch-data 4 get} bind def	% number of pixels to left of origin
/ch-tfmw {ch-data 5 get} bind def	% spacing to next character

/CharBuilder {	% fontdict ch Charbuilder -	-- image one character
    /ch-code exch def		% save the char code
    /font-dict exch def		% and the font dict.
    % get the bitmap descriptor for char
    /ch-data font-dict /BitMaps get ch-code get def
    ch-data null eq not {
	ch-tfmw 0
	ch-xoff neg  ch-yoff neg ch-width ch-xoff sub ch-height ch-yoff sub
	setcachedevice
	ch-width ch-height true [1 0  0 1  ch-xoff ch-yoff]
	{ch-image} imagemask
    } if
} bind def

/NF2 {	% corr size id NF2 -	-- initialize a new font dictionary
    /newname exch def
    /fsize exch def
    /corr exch def
    newname 7 dict def	% allocate new font dictionary
    newname load begin
	/FontType 3 def
	/FontMatrix [corr 0 0 corr neg 0 0] def
	/FontBBox [0 0 1 1] def
	/BitMaps fsize array def
	/BuildChar /CharBuilder2 load def
	/Encoding 256 array def
	0 1 255 {Encoding exch /.notdef put} for
    end
    newname newname load definefont pop
} bind def

/CharBuilder2 {	% fontdict ch Charbuilder2 -	-- image one character
    /ch-code exch def		% save the char code
    /font-dict exch def		% and the font dict.
    % get the bitmap descriptor for char
    /ch-data font-dict /BitMaps get ch-code get def
    ch-data null eq not {
	ch-tfmw 0
	ch-xoff neg  ch-yoff neg ch-width ch-xoff sub ch-height ch-yoff sub
	setcachedevice
	ch-xoff neg ch-yoff neg translate
	ch-image exec
    } if
} bind def

/BFT {	% id id h v BFT -	-- use PS built-in font (type T)
    /bf-v exch def
    /bf-h exch def
    findfont [bf-h 0 0 bf-v 0 0] makefont def
} bind def

/BFE /BFT load def	%	-- use PS built-in font (type N,E)

/BFF {	% stand id id h v BFF -	-- use PS built-in font (type S,F)
    /bf-v exch def
    /bf-h exch def
    /savecurfont currentfont def
    findfont dup setfont		% stand id font
    3 -1 roll				% id font stand
    /bf-stand exch def			% id font
    [
	bf-stand stringwidth pop		% w (= width of standard char)
	dup bf-h exch div			% w bf-h/w
	exch bf-v exch div 0 0 3 -1 roll	% bf-h/w 0 0 bf-v/w
	0 0
    ] makefont def
    savecurfont setfont
} bind def

/SF /setfont load def	% fontdict SF -        -- make that the current font
% in the following, the font-cacheing mechanism requires that
% a name unique in the particular font be generated

/s3 3 string def
/D {	% char-data ch D -    -- define a new character bitmap
    /ch-code exch def
    /ch-data exch def
    currentfont /BitMaps get ch-code ch-data put
    currentfont /Encoding get ch-code
    dup s3 cvs cvn   % generate a unique name simply from the character code
    put
} bind def

/BP {	% - BP -        -- begin a brand new page
    userdict /bop-hook known { bop-hook } if
    /SaveImage save def
    xoffset yoffset translate
    leftm topm
    landscape {
	exch translate
	90 rotate
    }{
	paperheight exch sub translate
    } ifelse
    72 Resolution div dup neg scale
    0 0 moveto
} def

/EP {	% - EP -              -- end a page
    SaveImage restore
    userdict /eop-hook known { eop-hook } if
    showpage
} def

/START {	% resolution dvimag START -	-- start everything
    userdict /start-hook known { start-hook } if
    /DVImag exch def
    /magscale true def
    /Resolution exch def
} def

%/END {	% - END -		-- done the whole shebang
%    end
%    userdict /end-hook known { end-hook } if
%} def

/l /lineto load def	% x y l -		-- draw line
/p /moveto load def	% x y p -		-- move to position
/r {			% x r -			-- move right
    0 rmoveto
} bind def
/s /show load def	% string s -		-- show the string
/c /curveto load def

/rs {			% string vs -		-- show the rotated string
    90 rotate show -90 rotate
} bind def

/ru {		% dx dy ru -			-- set a rule (rectangle)
    /dy exch neg def	% because dy is height up from bottom
    /dx exch def
    /x currentpoint /y exch def def	% remember current point
    newpath x y moveto
    dx 0 rlineto
    0 dy rlineto
    dx neg 0 rlineto
    closepath fill
    x y moveto
} bind def

end % TeXDict