| 1 |
% tex.lpro - public domain. |
| 2 |
% |
| 3 |
% The following defines procedures assumed and used by program "dvips" |
| 4 |
% and must be downloaded or sent as a header file for all TeX jobs. |
| 5 |
% Originated by Neal Holtz, Carleton University, Ottawa, Canada |
| 6 |
% <[email protected]> |
| 7 |
% June, 1985 |
| 8 |
% |
| 9 |
% Hacked by tgr, July 1987, stripped down to bare essentials, |
| 10 |
% plus a few new commands for speed. |
| 11 |
% |
| 12 |
% Hacked by don, December 1989, to give characters top down and to |
| 13 |
% remove other small nuisances; merged with tgr's compression scheme |
| 14 |
% |
| 15 |
% To convert this file into a downloaded file instead of a header |
| 16 |
% file, uncomment all of the lines beginning with %-% |
| 17 |
% |
| 18 |
% To observe available VM, uncomment the following. |
| 19 |
% (The first ten lines define a general 'printnumber' routine.) |
| 20 |
% |
| 21 |
% /VirginMtrx 6 array currentmatrix def |
| 22 |
% /dummystring 20 string def |
| 23 |
% /numberpos 36 def |
| 24 |
% /printnumber { gsave VirginMtrx setmatrix |
| 25 |
% /Helvetica findfont 10 scalefont setfont |
| 26 |
% 36 numberpos moveto |
| 27 |
% /numberpos numberpos 12 add def |
| 28 |
% dummystring cvs show |
| 29 |
% grestore |
| 30 |
% } bind def |
| 31 |
% /showVM { vmstatus exch sub exch pop printnumber } def |
| 32 |
% /eop-aux { showVM } def |
| 33 |
% |
| 34 |
%-%0000000 % Server loop exit password |
| 35 |
%-%serverdict begin exitserver |
| 36 |
%-% systemdict /statusdict known |
| 37 |
%-% {statusdict begin 9 0 3 setsccinteractive /waittimeout 300 def end} |
| 38 |
%-% if |
| 39 |
|
| 40 |
/TeXDict 300 dict def % define a working dictionary |
| 41 |
TeXDict begin % start using it. |
| 42 |
/N {def} def |
| 43 |
/B {bind def} N |
| 44 |
/S {exch} N |
| 45 |
/X { S N } B |
| 46 |
/A {dup} B |
| 47 |
/TR {translate} N |
| 48 |
|
| 49 |
% The output of dvips assumes pixel units, Resolution/inch, with |
| 50 |
% increasing y coordinates corresponding to moving DOWNWARD. |
| 51 |
% The PostScript default is big point units (bp), 72/inch, with |
| 52 |
% increasing y coordinates corresponding to moving UP; the |
| 53 |
% following routines handle conversion to dvips conventions. |
| 54 |
|
| 55 |
% Let the PostScript origin be (xps,yps) in dvips coordinates. |
| 56 |
|
| 57 |
/isls false N |
| 58 |
/vsize 11 72 mul N |
| 59 |
/hsize 8.5 72 mul N |
| 60 |
/landplus90 { false } def % make this true to flip landscape |
| 61 |
|
| 62 |
/@rigin % -xps -yps @rigin - establishes dvips conventions |
| 63 |
{ isls { [ 0 landplus90 { 1 -1 } { -1 1 } ifelse 0 0 0 ] concat } if |
| 64 |
72 Resolution div 72 VResolution div neg scale |
| 65 |
isls { landplus90 { VResolution 72 div vsize mul 0 exch } |
| 66 |
{ Resolution -72 div hsize mul 0 } ifelse TR } if |
| 67 |
Resolution VResolution vsize -72 div 1 add mul TR |
| 68 |
% As bad as setmatrix is, it is better than misalignment. |
| 69 |
[ matrix currentmatrix |
| 70 |
{ A A round sub abs 0.00001 lt {round} if } forall |
| 71 |
round exch round exch |
| 72 |
] setmatrix } N |
| 73 |
|
| 74 |
/@landscape { /isls true N } B |
| 75 |
|
| 76 |
/@manualfeed |
| 77 |
{ statusdict /manualfeed true put |
| 78 |
} B |
| 79 |
|
| 80 |
% n @copies - set number of copies |
| 81 |
/@copies |
| 82 |
{ /#copies X |
| 83 |
} B |
| 84 |
|
| 85 |
% Bitmap fonts are called Fa, Fb, ..., Fz, F0, F1 . . . Ga . . . |
| 86 |
% The calling sequence for downloading font foo is |
| 87 |
% /foo df charde1 ... chardefn E |
| 88 |
% where each chardef is |
| 89 |
% <hexstring> wd ht xoff yoff dx charno D |
| 90 |
% or <hexstring> wd ht xoff yoff dx I |
| 91 |
% or <hexstring> charno D |
| 92 |
% or <hexstring> I |
| 93 |
|
| 94 |
/FMat [1 0 0 -1 0 0] N |
| 95 |
/FBB [0 0 0 0] N |
| 96 |
|
| 97 |
/nn 0 N /IEn 0 N /ctr 0 N |
| 98 |
/df-tail % id numcc maxcc df-tail -- initialize a new font dictionary |
| 99 |
{ |
| 100 |
% dmystr 2 fontname cvx (@@@@) cvs putinterval % put name in template |
| 101 |
/nn 8 dict N % allocate new font dictionary |
| 102 |
nn begin |
| 103 |
/FontType 3 N |
| 104 |
/FontMatrix fntrx N |
| 105 |
/FontBBox FBB N |
| 106 |
string /base X |
| 107 |
array /BitMaps X |
| 108 |
/BuildChar {CharBuilder} N |
| 109 |
/Encoding IEn N |
| 110 |
end |
| 111 |
A { /foo setfont } % dummy macro to be filled in |
| 112 |
2 array copy cvx N % have to allocate a new one |
| 113 |
load % now we change it |
| 114 |
% 0 dmystr 6 string copy % get a copy of the font name |
| 115 |
0 nn put |
| 116 |
% cvn cvx put % and stick it in the dummy macro |
| 117 |
/ctr 0 N % go, count, and etc. |
| 118 |
[ % start next char definition |
| 119 |
} B |
| 120 |
/sf 0 N |
| 121 |
/df { |
| 122 |
/sf 1 N |
| 123 |
/fntrx FMat N |
| 124 |
df-tail |
| 125 |
} B |
| 126 |
/dfs { div /sf X |
| 127 |
/fntrx [ sf 0 0 sf neg 0 0 ] N |
| 128 |
df-tail |
| 129 |
} B |
| 130 |
|
| 131 |
/E { pop nn A definefont setfont } B |
| 132 |
|
| 133 |
% the following is the only character builder we need. it looks up the |
| 134 |
% char data in the BitMaps array, and paints the character if possible. |
| 135 |
% char data -- a bitmap descriptor -- is an array of length 6, of |
| 136 |
% which the various slots are: |
| 137 |
|
| 138 |
/Cw {Cd A length 5 sub get} B % the number of pixels across |
| 139 |
/Ch {Cd A length 4 sub get} B % the number of pixels tall |
| 140 |
/Cx {128 Cd A length 3 sub get sub} B % num pixels right of origin |
| 141 |
/Cy {Cd A length 2 sub get 127 sub} B % number of pixels below origin |
| 142 |
/Cdx {Cd A length 1 sub get} B % number of pixels to next character |
| 143 |
/Ci {Cd A type /stringtype ne |
| 144 |
{ ctr get /ctr ctr 1 add N } if |
| 145 |
} B % the hex string image, or array of same |
| 146 |
% begin code for uncompressed fonts only |
| 147 |
/CharBuilder % fontdict ch Charbuilder - -- image one character |
| 148 |
{save 3 1 roll S A /base get 2 index get S /BitMaps get S get |
| 149 |
/Cd X pop |
| 150 |
/ctr 0 N |
| 151 |
Cdx 0 Cx Cy Ch sub |
| 152 |
Cx Cw add Cy |
| 153 |
setcachedevice |
| 154 |
Cw Ch true |
| 155 |
[1 0 0 -1 -.1 Cx sub Cy .1 sub] |
| 156 |
{Ci} imagemask |
| 157 |
restore |
| 158 |
} B |
| 159 |
% end code for uncompressed fonts only |
| 160 |
% % here's the alternate code for unpacking compressed fonts |
| 161 |
% /id 0 N /rw 0 N /rc 0 N /gp 0 N /cp 0 N /G 0 N |
| 162 |
% /CharBuilder % fontdict ch Charbuilder - -- image one character |
| 163 |
% {save 3 1 roll S A /base get 2 index get S /BitMaps get S get |
| 164 |
% /Cd X pop |
| 165 |
% /ctr 0 N |
| 166 |
% Cdx 0 Cx Cy Ch sub |
| 167 |
% Cx Cw add Cy |
| 168 |
% setcachedevice |
| 169 |
% Cw Ch true |
| 170 |
% [1 0 0 -1 -.1 Cx sub Cy .1 sub] |
| 171 |
% /id Ci N % image data |
| 172 |
% /rw Cw 7 add 8 idiv string N % row, initially zero |
| 173 |
% /rc 0 N % repeat count |
| 174 |
% /gp 0 N % image data pointer |
| 175 |
% /cp 0 N % column pointer |
| 176 |
% { rc 0 ne { rc 1 sub /rc X rw } { G } ifelse } imagemask |
| 177 |
% restore |
| 178 |
% } B |
| 179 |
% /G { { id gp get /gp gp 1 add N |
| 180 |
% A 18 mod S 18 idiv pl S get exec } loop } B |
| 181 |
% /adv { cp add /cp X } B |
| 182 |
% /chg { rw cp id gp 4 index getinterval putinterval |
| 183 |
% A gp add /gp X adv } B |
| 184 |
% /nd { /cp 0 N rw exit } B |
| 185 |
% /lsh { rw cp 2 copy get A 0 eq { pop 1 } { A 255 eq { pop 254 } |
| 186 |
% { A A add 255 and S 1 and or } ifelse } ifelse put 1 adv } B |
| 187 |
% /rsh { rw cp 2 copy get A 0 eq { pop 128 } { A 255 eq { pop 127 } |
| 188 |
% { A 2 idiv S 128 and or } ifelse } ifelse put 1 adv } B |
| 189 |
% /clr { rw cp 2 index string putinterval adv } B |
| 190 |
% /set { rw cp fillstr 0 4 index getinterval putinterval adv } B |
| 191 |
% /fillstr 18 string 0 1 17 { 2 copy 255 put pop } for N |
| 192 |
% /pl [ |
| 193 |
% { adv 1 chg } |
| 194 |
% { adv 1 chg nd } |
| 195 |
% { 1 add chg } |
| 196 |
% { 1 add chg nd } |
| 197 |
% { adv lsh } |
| 198 |
% { adv lsh nd } |
| 199 |
% { adv rsh } |
| 200 |
% { adv rsh nd } |
| 201 |
% { 1 add adv } |
| 202 |
% { /rc X nd } |
| 203 |
% { 1 add set } |
| 204 |
% { 1 add clr } |
| 205 |
% { adv 2 chg } |
| 206 |
% { adv 2 chg nd } |
| 207 |
% { pop nd } ] A { bind pop } forall N |
| 208 |
% % end of code for unpacking compressed fonts |
| 209 |
|
| 210 |
/D % char-data ch D - -- define character bitmap in current font |
| 211 |
{ /cc X |
| 212 |
A type /stringtype ne {]} if |
| 213 |
nn /base get cc ctr put |
| 214 |
nn /BitMaps get S ctr S |
| 215 |
sf 1 ne { |
| 216 |
A A length 1 sub A 2 index S get sf div put |
| 217 |
} if |
| 218 |
put |
| 219 |
/ctr ctr 1 add N |
| 220 |
} B |
| 221 |
|
| 222 |
/I % a faster D for when the next char follows immediately |
| 223 |
{ cc 1 add D } B |
| 224 |
|
| 225 |
/bop % %t %d bop - -- begin a brand new page, %t=pageno %d=seqno |
| 226 |
{ |
| 227 |
userdict /bop-hook known { bop-hook } if |
| 228 |
/SI save N |
| 229 |
@rigin |
| 230 |
% |
| 231 |
% Now we check the resolution. If it's correct, we use RV as V, |
| 232 |
% otherwise we use QV. |
| 233 |
% |
| 234 |
0 0 moveto |
| 235 |
/V matrix currentmatrix |
| 236 |
A 1 get A mul exch 0 get A mul add .99 lt |
| 237 |
{/QV} {/RV} ifelse load def |
| 238 |
pop pop |
| 239 |
} N |
| 240 |
|
| 241 |
/eop % - eop - -- end a page |
| 242 |
{ % eop-aux % -- to observe VM usage |
| 243 |
SI restore |
| 244 |
userdict /eop-hook known { eop-hook } if |
| 245 |
showpage |
| 246 |
} N |
| 247 |
|
| 248 |
/@start % hsz vsz mag dpi vdpi name @start - -- start everything |
| 249 |
{ |
| 250 |
userdict /start-hook known { start-hook } if |
| 251 |
pop % the job name string is used only by start-hook |
| 252 |
/VResolution X |
| 253 |
/Resolution X |
| 254 |
1000 div /DVImag X |
| 255 |
/IEn 256 array N |
| 256 |
2 string 0 1 255 { IEn S A 360 add 36 4 index cvrs cvn put } for pop |
| 257 |
65781.76 div /vsize X |
| 258 |
65781.76 div /hsize X |
| 259 |
} N |
| 260 |
|
| 261 |
/dir 0 def |
| 262 |
/dyy {/dir 0 def |
| 263 |
} B |
| 264 |
/dyt {/dir 1 def |
| 265 |
} B |
| 266 |
/dty {/dir 2 def |
| 267 |
} B |
| 268 |
/dtt {/dir 3 def |
| 269 |
} B |
| 270 |
|
| 271 |
%/p {show} N % the main character setting routine |
| 272 |
/p {dir 2 eq |
| 273 |
{-90 rotate show 90 rotate} |
| 274 |
{dir 3 eq {-90 rotate show 90 rotate} |
| 275 |
{show} ifelse} ifelse |
| 276 |
} N |
| 277 |
|
| 278 |
/RMat [ 1 0 0 -1 0 0 ] N % things we need for rules |
| 279 |
/BDot 260 string N |
| 280 |
/Rx 0 N /Ry 0 N |
| 281 |
% |
| 282 |
% What we need to do to get things to work here is tragic. |
| 283 |
% |
| 284 |
/V {} B /RV |
| 285 |
/v { % can't use ...fill; it makes rules too big |
| 286 |
/Ry X /Rx X |
| 287 |
V |
| 288 |
} B |
| 289 |
% |
| 290 |
% Which do we use? The first if we are talking to Display |
| 291 |
% PostScript, the latter otherwise. |
| 292 |
% |
| 293 |
statusdict begin /product where |
| 294 |
{ pop false [(Display) (NeXT) (LaserWriter 16/600)] { |
| 295 |
A length product length le { |
| 296 |
A length product exch 0 exch getinterval eq |
| 297 |
{ pop true exit } if |
| 298 |
} { pop } ifelse |
| 299 |
} forall } |
| 300 |
{ false } ifelse end |
| 301 |
{ { |
| 302 |
gsave |
| 303 |
TR -.1 .1 TR 1 1 scale Rx Ry |
| 304 |
false RMat { BDot } imagemask |
| 305 |
grestore |
| 306 |
} } |
| 307 |
{ { |
| 308 |
gsave |
| 309 |
TR -.1 .1 TR Rx Ry scale 1 1 |
| 310 |
false RMat { BDot } imagemask |
| 311 |
grestore |
| 312 |
} } ifelse B |
| 313 |
% |
| 314 |
% We use this if the resolution doesn't match. |
| 315 |
% |
| 316 |
/QV { |
| 317 |
gsave |
| 318 |
newpath transform round exch round exch itransform moveto |
| 319 |
Rx 0 rlineto 0 Ry neg rlineto |
| 320 |
Rx neg 0 rlineto fill |
| 321 |
grestore |
| 322 |
} B |
| 323 |
% |
| 324 |
/a { moveto } B % absolute positioning |
| 325 |
/delta 0 N % we need a variable to hold space moves |
| 326 |
% |
| 327 |
% The next ten macros allow us to make horizontal motions that |
| 328 |
% are within 4 of the previous horizontal motion with a single |
| 329 |
% character. These are typically used for spaces. |
| 330 |
% |
| 331 |
/tail { A /delta X 0 rmoveto } B |
| 332 |
/M { S p delta add tail } B |
| 333 |
/b { S p tail } B % show and tail! |
| 334 |
/c { -4 M } B |
| 335 |
/d { -3 M } B |
| 336 |
/e { -2 M } B |
| 337 |
/f { -1 M } B |
| 338 |
/g { 0 M } B |
| 339 |
/h { 1 M } B |
| 340 |
/i { 2 M } B |
| 341 |
/j { 3 M } B |
| 342 |
/k { 4 M } B |
| 343 |
% |
| 344 |
% These next allow us to make small motions (-4..4) cheaply. |
| 345 |
% Typically used for kerns. |
| 346 |
% |
| 347 |
/w { 0 rmoveto } B |
| 348 |
/l { p -4 w } B |
| 349 |
/m { p -3 w } B |
| 350 |
/n { p -2 w } B |
| 351 |
/o { p -1 w } B |
| 352 |
/q { p 1 w } B |
| 353 |
/r { p 2 w } B |
| 354 |
/s { p 3 w } B |
| 355 |
/t { p 4 w } B |
| 356 |
% |
| 357 |
% x is good for small vertical positioning. |
| 358 |
% And y is good for a print followed by a move. |
| 359 |
% |
| 360 |
/x { 0 S rmoveto } B |
| 361 |
/y { 3 2 roll p a } B |
| 362 |
% |
| 363 |
% The bos and eos commands bracket sections of downloaded characters. |
| 364 |
% |
| 365 |
/bos { /SS save N } B |
| 366 |
/eos { SS restore } B |
| 367 |
|
| 368 |
end % revert to previous dictionary |