#
source:
trunk/third/tex/xdvi/psheader.txt
@
9103

Revision 9103, 7.4 KB checked in by ghudson, 28 years ago (diff) |
---|

Line | |
---|---|

1 | %% These are from tex.lpro |

2 | /TeXDict 250 dict def % define a working dictionary ( IBM: color - 200->250 ) |

3 | TeXDict begin % start using it. |

4 | /N {def} def |

5 | /B {bind def} N |

6 | /S {exch} N |

7 | /X { S N } B |

8 | /TR {translate} N |

9 | end % TeXDict |

10 | |

11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |

12 | %% header for the \special command |

13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |

14 | % The structure of the PostScript produced by dvips for \special is: |

15 | % @beginspecial |

16 | % - any number of @hsize, @hoffset, @hscale, etc., commands |

17 | % @setspecial |

18 | % - the user's file of PostScript commands |

19 | % @endspecial |

20 | |

21 | TeXDict begin |

22 | /SDict 200 dict N |

23 | SDict begin |

24 | |

25 | /@SpecialDefaults |

26 | { /hs 612 N |

27 | /vs 792 N |

28 | /ho 0 N |

29 | /vo 0 N |

30 | /hsc 1 N |

31 | /vsc 1 N |

32 | /ang 0 N |

33 | /CLIP 0 N |

34 | /rwiSeen false N |

35 | /rhiSeen false N |

36 | /letter {} N /note {} N /a4 {} N /legal {} N |

37 | } B |

38 | |

39 | % |

40 | % The following definition sets up the units that hscale/vscale are in. |

41 | % For certain sites this might require change, but it is |

42 | % recommended instead that any macro packages that require |

43 | % hscale/vscale set the units appropriately via |

44 | % |

45 | % \special{! /@scaleunit 1 def } |

46 | % |

47 | % if global, or |

48 | % |

49 | % \special{" /@scaleunit 1 def } |

50 | % |

51 | % before each instance if multiple macro packages with |

52 | % different requirements are being used. |

53 | % |

54 | /@scaleunit 100 N |

55 | % s @hscale - set scale factor |

56 | /@hscale {@scaleunit div /hsc X} B |

57 | /@vscale {@scaleunit div /vsc X} B |

58 | |

59 | % d @hsize - specify a horizontal clipping dimension |

60 | /@hsize {/hs X /CLIP 1 N} B |

61 | /@vsize {/vs X /CLIP 1 N} B |

62 | |

63 | /@clip {/CLIP 2 N} B |

64 | |

65 | % d @hoffset - specify a shift for the figure |

66 | /@hoffset {/ho X} B |

67 | /@voffset {/vo X} B |

68 | |

69 | % a @angle - set rotation angle |

70 | /@angle {/ang X} B |

71 | |

72 | % |

73 | % Here we handle bounding box calculations, if necessary. |

74 | % |

75 | /@rwi { 10 div /rwi X /rwiSeen true N } B % rwi will be real width after scaling |

76 | /@rhi { 10 div /rhi X /rhiSeen true N } B % rhi will be real height after scaling |

77 | /@llx { /llx X } B |

78 | /@lly { /lly X } B |

79 | /@urx { /urx X } B |

80 | /@ury { /ury X } B |

81 | |

82 | /magscale true def |

83 | |

84 | end % of SDict |

85 | |

86 | /@MacSetUp |

87 | { userdict /md known % if md is defined |

88 | { userdict /md get type /dicttype eq % and if it is a dictionary |

89 | { |

90 | userdict begin % expand it if necessary |

91 | md length 10 add md maxlength ge |

92 | {/md md dup length 20 add dict copy def}if |

93 | end |

94 | md begin % then redefine some stuff |

95 | /letter {} N |

96 | /note {} N |

97 | /legal {} N |

98 | /od{txpose |

99 | 1 0 mtx defaultmatrix dtransform S atan/pa X |

100 | newpath clippath mark |

101 | {transform{itransform moveto}} |

102 | {transform{itransform lineto}} |

103 | { 6 -2 roll transform |

104 | 6 -2 roll transform |

105 | 6 -2 roll transform |

106 | { itransform 6 2 roll |

107 | itransform 6 2 roll |

108 | itransform 6 2 roll |

109 | curveto |

110 | } |

111 | } |

112 | {{closepath}} |

113 | pathforall newpath counttomark array astore /gc xdf |

114 | pop ct 39 0 put |

115 | 10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if |

116 | }N |

117 | /txpose{ |

118 | pxs pys scale ppr aload pop |

119 | por { |

120 | noflips { |

121 | pop S neg S TR pop 1 -1 scale |

122 | }if |

123 | xflip yflip and { |

124 | pop S neg S TR 180 rotate 1 -1 scale |

125 | ppr 3 get ppr 1 get neg sub neg ppr 2 get |

126 | ppr 0 get neg sub neg TR |

127 | }if |

128 | xflip yflip not and { |

129 | pop S neg S TR pop 180 rotate |

130 | ppr 3 get ppr 1 get neg sub neg 0 TR |

131 | }if |

132 | yflip xflip not and { |

133 | ppr 1 get neg ppr 0 get neg TR |

134 | }if |

135 | } |

136 | { |

137 | noflips { |

138 | TR pop pop 270 rotate 1 -1 scale |

139 | }if |

140 | xflip yflip and { |

141 | TR pop pop 90 rotate 1 -1 scale |

142 | ppr 3 get ppr 1 get neg sub neg ppr 2 get |

143 | ppr 0 get neg sub neg TR |

144 | }if |

145 | xflip yflip not and { |

146 | TR pop pop 90 rotate ppr 3 get |

147 | ppr 1 get neg sub neg 0 TR |

148 | }if |

149 | yflip xflip not and { |

150 | TR pop pop 270 rotate ppr 2 get |

151 | ppr 0 get neg sub neg 0 S TR |

152 | }if |

153 | }ifelse |

154 | scaleby96 { |

155 | ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy |

156 | TR .96 dup scale neg S neg S TR |

157 | }if |

158 | }N |

159 | /cp {pop pop showpage pm restore}N |

160 | end |

161 | }if |

162 | } if |

163 | } N |

164 | |

165 | % |

166 | % The following procedure brings us back to PostScript size. It takes |

167 | % into account the current global dvi magnification, so graphics |

168 | % scale with the document. |

169 | % |

170 | /normalscale { |

171 | Resolution 72 div VResolution 72 div neg scale |

172 | magscale { DVImag dup scale } if |

173 | 0 setgray |

174 | } N |

175 | % |

176 | % We need the psfig macros. |

177 | % |

178 | % All software, documentation, and related files in this distribution of |

179 | % psfig/tex are Copyright (c) 1987 Trevor J. Darrell |

180 | % |

181 | % Permission is granted for use and non-profit distribution of psfig/tex |

182 | % providing that this notice be clearly maintained, but the right to |

183 | % distribute any portion of psfig/tex for profit or as part of any commercial |

184 | % product is specifically reserved for the author. |

185 | % |

186 | % |

187 | % psfigTeX PostScript Prolog |

188 | % $Header: /afs/dev.mit.edu/source/repository/third/tex/xdvi/psheader.txt,v 1.1.1.1 1996-10-09 06:42:21 ghudson Exp $ |

189 | % |

190 | /psfts { S 65781.76 div N } N |

191 | |

192 | % x y bb-llx bb-lly bb-urx bb-ury startTexFig - |

193 | /startTexFig { |

194 | /psf$SavedState save N |

195 | userdict maxlength dict begin |

196 | |

197 | /magscale true def |

198 | normalscale |

199 | currentpoint TR %set the current point as the user's origin |

200 | |

201 | /psf$ury psfts |

202 | /psf$urx psfts |

203 | /psf$lly psfts |

204 | /psf$llx psfts |

205 | /psf$y psfts |

206 | /psf$x psfts |

207 | |

208 | /psf$sx psf$x psf$urx psf$llx sub div N % scaling for x |

209 | /psf$sy psf$y psf$ury psf$lly sub div N % scaling for y |

210 | |

211 | psf$sx psf$sy scale % scale by (sx,sy) |

212 | |

213 | psf$llx neg psf$ury neg TR |

214 | |

215 | /showpage { |

216 | } N |

217 | /erasepage { |

218 | } N |

219 | /copypage { |

220 | } N |

221 | /p 3 def % necessary to get around a bug in Adobe Illustrator |

222 | @MacSetUp |

223 | } N |

224 | |

225 | % llx lly urx ury doclip - (args in figure coordinates) |

226 | /doclip { |

227 | psf$llx psf$lly psf$urx psf$ury |

228 | currentpoint 6 2 roll |

229 | newpath 4 copy |

230 | 4 2 roll moveto |

231 | 6 -1 roll S lineto |

232 | S lineto |

233 | S lineto |

234 | closepath clip |

235 | newpath |

236 | moveto |

237 | } N |

238 | % - endTexFig - |

239 | /endTexFig { end psf$SavedState restore } N |

240 | |

241 | % this will be invoked as the result of a \special command (for the |

242 | % inclusion of PostScript graphics). The basic idea is to change all |

243 | % scaling and graphics back to defaults, but to shift the origin |

244 | % to the current position on the page. |

245 | |

246 | /@beginspecial % - @beginspecial - -- enter special mode |

247 | { SDict begin |

248 | /SpecialSave save N |

249 | gsave |

250 | normalscale |

251 | currentpoint TR %set the current point as the user's origin |

252 | @SpecialDefaults % setup default offsets, scales, sizes, and angle |

253 | count /ocount X /dcount countdictstack N |

254 | } N |

255 | |

256 | /@setspecial % to setup user specified offsets, scales, sizes (for clipping) |

257 | { |

258 | CLIP 1 eq |

259 | { newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto |

260 | closepath clip } |

261 | if |

262 | ho vo TR |

263 | hsc vsc scale |

264 | ang rotate |

265 | rwiSeen { |

266 | rwi urx llx sub div |

267 | rhiSeen { rhi ury lly sub div } { dup } ifelse |

268 | scale llx neg lly neg TR |

269 | } { |

270 | rhiSeen { rhi ury lly sub div dup scale llx neg lly neg TR } if |

271 | } ifelse |

272 | CLIP 2 eq |

273 | { newpath llx lly moveto urx lly lineto urx ury lineto llx ury lineto |

274 | closepath clip } |

275 | if |

276 | /showpage {} N |

277 | /erasepage {} N |

278 | /copypage {} N |

279 | newpath |

280 | } N |

281 | |

282 | /@endspecial % - @endspecial - -- leave special mode |

283 | { count ocount sub {pop} repeat |

284 | countdictstack dcount sub {end} repeat |

285 | grestore SpecialSave restore |

286 | end |

287 | } N |

288 | /@defspecial |

289 | { |

290 | SDict begin |

291 | } N |

292 | /@fedspecial |

293 | { |

294 | end |

295 | } B |

296 | end % revert to previous dictionary |

**Note:**See TracBrowser for help on using the repository browser.