home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !tex / TeXInputs / DviAlw / ps
Encoding:
Text File  |  1989-06-14  |  10.2 KB  |  326 lines

  1. % <BEEBE.TEX.DVI>DVIALW.PS.19, 20-Sep-88 10:58:09, Edit by BEEBE
  2. % Modify BOJ to use default matrix if neither note nor letter are known
  3. % Add commented-out Ctl-D macro for use on DEC-LPS40
  4. % <BEEBE.TEX.DVI>DVIALW.PS.18,  1-Sep-88 18:03:44, Edit by BEEBE
  5. % Increase BitMaps array in NF macro from 128 to 256 entries to support
  6. % extended 8-bit character sets
  7. % <BEEBE.TEX.DVI>DVIALW.PS.17, 18-Sep-87 17:48:04, Edit by BEEBE
  8. % Add test for note paper and if unknown, use letter paper instead.
  9. % Non-Apple PostScript implementations do not know about note paper
  10. % but its use on the Apple LaserWriter gains 92K of virtual memory
  11. % <BEEBE.TEX.DVI>DVIALW.PS.16, 18-Sep-87 15:50:52, Edit by BEEBE
  12. % Modify coordinate computations to remove round-off errors
  13. % in landscape mode, and correct landscape page origin
  14. % <BEEBE.TEX.DVI>DVIALW.PS.14, 22-Jun-87 09:55:05, Edit by BEEBE
  15. % Add missing "0 900 translate Mtrx currentmatrix pop" to /LEGAL
  16. % <BEEBE.TEX.DVI>DVIALW.PS.13,  7-Jan-87 17:38:51, Edit by BEEBE
  17. % Add translate command to BOP so that (0,0) really corresponds to
  18. % the top left physical page corner.  The standard LaTeX file
  19. % TESTPAGE.TEX can be used for this calibration; it might be sensitive
  20. % to the particular printer used.
  21. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.12, 10-Dec-86 17:24:50, Edit by BEEBE
  22. % Fix off-by-one error in definition of /B; to draw a box N pixels
  23. % wide, microscopic examination of output shows that the box width
  24. % must be N-1, not N, pixels; the boundary counts in the filling.
  25. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.9, 28-Nov-86 19:00:52, Edit by BEEBE
  26. % Change definition of EOP to use #copies and showpage
  27. % instead of {copypage} repeat erasepage
  28. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.7, 16-Oct-86 13:09:36, Edit by BEEBE
  29. % Following Macintosh LaserWriter md dictionary, change most
  30. % def's to bdf's (bind def); this is claimed to speed up
  31. % operator access
  32. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.5, 16-Oct-86 12:01:12, Edit by BEEBE
  33. % Change CTL-L to caret-L in comment
  34. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.3, 13-Jun-86 10:48:39, Edit by BEEBE
  35. % Fix definition of NOTE, make it default in BOJ macro to try to reduce
  36. % incidence of VM errors
  37. % ----------------------------------------------------------------------
  38. % DVIALW PostScript macro definitions (keep in alphabetical order).  For
  39. % readability, these  are  heavily  commented,  but  we  adhere  to  the
  40. % convention that  percent is  used  ONLY to  mark  the beginning  of  a
  41. % comment (NEVER  occurs  inside a  PostScript  string), and  lines  are
  42. % limited to 80 characters.  That way, DVIALW can read these definitions
  43. % from a  file and  discard  comments and  trailing white  space  before
  44. % transmission to  the  PostScript output  file.   In the  interests  of
  45. % compactness, macros which  receive any significant  degree of use  are
  46. % given single letter names -- PostScript is already much too verbose.
  47. %
  48. % Coordinates are assumed to  be in pixels  (Resolution per inch).   The
  49. % page origin follows the  PostScript convention of  being in the  lower
  50. % left corner, y positive upwards along  the longer side of the page,  x
  51. % positive  to  the  right.   Letter  and  legal  sizes  are   therefore
  52. % equivalent as far as PostScript is concerned, but y coordinates can be
  53. % bigger in legal size.  In landscape mode, the page is rotated to place
  54. % the origin in  the upper left  corner, x positive  downward along  the
  55. % longer side of  the page, y  positive to the  right.  That way,  pages
  56. % eject from  the printer  upright when  viewed from  the front  of  the
  57. % printer.
  58. %
  59. % Document format is something like this:
  60. %
  61. %    %!PS-Adobe-1.0
  62. %    %%Dimensions: 0 0 612 792
  63. %    %%Title: DVIALW  -o1 -s300 foo12
  64. %    %%CreationDate: Sat Mar  8 10:52:52 1986
  65. %    %%Creator: BEEBE and [TeX82 DVI Translator Version 2.03b...]
  66. %    %%Pages: (atend)
  67. %    %%BugHistory: Incorporates save/restore and font reloading...
  68. %    %%BugHistory: Incorporates Allan Hetzel's 31-Oct-85 DARPA...
  69. %    %%EndComments
  70. %    %%EndProlog
  71. %    %%Page: 0 1
  72. %    TeXdict begin
  73. %    BOJ
  74. %    BOP
  75. %    ...
  76. %     1 EOP
  77. %    ~LBOP
  78. %    ...
  79. %     1 EOP
  80. %    ~LBOP
  81. %    ...
  82. %     1 EOP
  83. %    ~LEOJ
  84. %    %%Trailer
  85. %    %%Pages: 7
  86. %    %%PageTable:  0 1 3434
  87. %    ~D
  88. %
  89. % One formfeed is output  for each printed page  copy, in order to  make
  90. % spooler page accounting simple.  The additional comments wrapping  the
  91. % BOJ ..  EOJ  sequence conform  to  Adobe PostScript  file  structuring
  92. % conventions, and the first line can be used by the spooler to identify
  93. % the file as containing PostScript.
  94. % ----------------------------------------------------------------------
  95.  
  96.  
  97. % control D (EOT) -- do nothing.
  98. % Usage -- for  PostScript printers  that do not  use the  LaserWriter's
  99. % serial  protocol,  the  ~D  described  above  will  be  sent  to   the
  100. % interpreter for  execution.  Make  sure that  it does  nothing.   This
  101. % definition must be outside TeXdict since  it is invoked at the end  of
  102. % file, after TeXdict is removed from the stack by EOJ.
  103. %
  104. % Remove the following 3 %%% lines for such printers.
  105. %%%(\004) cvn
  106. %%%{
  107. %%%} def
  108. statusdict
  109. begin
  110.     product            % this gets printer name
  111.     (PrintServer 40) eq        % if DEC LPS-40
  112.     {(\004) cvn{ } def}        % then make Ctl-d a no-op
  113.     {}                % else do nothing
  114.     ifelse
  115. end
  116.  
  117. /TeXdict 200 dict def        % dictionary for these definitions
  118. TeXdict begin
  119.  
  120. % bdf -- bind def (for efficiency)
  121. % Usage -- just like def, but not on constant objects
  122. /bdf {bind def} def
  123.  
  124. % B -- draw bar (TeX rule) of size w by h at currentpoint
  125. % Usage -- w h B
  126. /B
  127. {
  128.   /h exch def
  129.   /w exch def
  130.   gsave
  131.   currentpoint
  132.   newpath
  133.     moveto
  134.     w 1 sub 0 rlineto
  135.     0 h 1 sub rlineto
  136.     w 1 sub neg 0 rlineto
  137.   closepath fill
  138.   grestore
  139. } bdf
  140.  
  141. % BOJ -- beginning of job (EOF ends it and closes TeXdict)
  142. % Usage -- BOJ
  143. /BOJ
  144. {
  145.   72 Resolution div 72 Resolution div scale
  146.   userdict /note known
  147.   {NOTE}                % default page format for ALW
  148.   {userdict /letter known
  149.   {LETTER}                % default page format for others
  150.   {Mtrx currentmatrix pop} ifelse}    % if letter unknown, use current
  151.   ifelse
  152. } bdf
  153.  
  154. % BOP -- beginning of page
  155. % Usage -- BOP
  156. /BOP
  157. {
  158.   clear
  159.   Mtrx setmatrix
  160.   25 0 translate % Physical page origin is at (-25,0) from the top left corner
  161. } bdf
  162.  
  163. % ch-fieldname -- extract field from ch-data array (order defined by positions
  164. % in first array argument to macro D)
  165. % Usage -- ch-fieldname
  166. /ch-image  {ch-data 0 get} bdf    % the bitmap hex string image
  167. /ch-xoff   {ch-data 1 get} bdf    % pixels from left edge of bitmap to char origin
  168. /ch-yoff   {ch-data 2 get} bdf    % pixels from top edge of bitmap to char origin
  169. /ch-width  {ch-data 3 get} bdf    % bitmap width in pixels
  170. /ch-height {ch-data 4 get} bdf  % bitmap height in pixels
  171. /ch-tfmw   {ch-data 5 get} bdf    % pixels to next character (precise flt value)
  172.  
  173. % CharBuilder -- image one character
  174. % Usage -- fontdict ch CharBuilder
  175. /CharBuilder
  176. {
  177.   /ch-code exch def        % save the char code
  178.   /font-dict exch def        % and the font dict.
  179.   /ch-data font-dict /BitMaps get
  180.     ch-code get def        % get the bitmap descriptor for char
  181.   ch-data null eq not        % show character if entry is not empty
  182.   {
  183.     ch-tfmw                0
  184.     ch-xoff neg            ch-yoff ch-height sub
  185.     ch-width ch-xoff sub    ch-yoff
  186.     setcachedevice
  187.     0 0 SNAP translate
  188.     ch-width ch-height true [ 1 0 0 -1 ch-xoff ch-yoff ]
  189.     {ch-image} imagemask
  190.   } if
  191. } bdf
  192.  
  193.  
  194. % D -- define new character in current font
  195. % Usage -- [<bitmap> xoff yoff pixwid pixht tfmpixwid] charnum D
  196. /D
  197. {
  198.   /ch-code exch def
  199.   /ch-data exch def
  200.   currentfont /BitMaps get ch-code ch-data put
  201.   currentfont /Encoding get ch-code dup 3 string cvs cvn put
  202. } bdf
  203.  
  204. % EOJ -- end of job
  205. % Usage -- EOJ
  206. /EOJ
  207. {
  208.   end                % matches begin issued before BOJ
  209. } bdf
  210.  
  211. % EOP -- end of page
  212. % Usage -- ncopies EOP
  213. /EOP
  214. {
  215. /#copies exch def
  216. showpage
  217. } bdf
  218.  
  219. % LANDSCAPE -- landscape format page (11inH x 8.5inV)
  220. % Usage -- LANDSCAPE
  221. /LANDSCAPE
  222. {
  223.   letter initmatrix
  224.   72 Resolution div dup scale
  225.   0 3300 translate
  226.   -90 rotate
  227.   0 -750 translate
  228.   Mtrx currentmatrix pop
  229. } bdf
  230.  
  231. % LEGAL -- legal format page (8.5inH x 13inV)
  232. % Usage -- LEGAL
  233. /LEGAL
  234. {
  235.   legal initmatrix
  236.   72 Resolution div dup scale
  237.   0 900 translate
  238.   Mtrx currentmatrix pop
  239. } bdf
  240.  
  241. % LETTER -- letter format page
  242. % Usage -- LETTER
  243. /LETTER
  244. {
  245.   letter initmatrix
  246.   72 Resolution div dup scale
  247.   Mtrx currentmatrix pop
  248. } bdf
  249.  
  250. % M -- moveto
  251. % Usage -- x y M
  252. /M
  253. {
  254.   moveto
  255. } bdf
  256.  
  257. % Mtrx -- permanent storage for page transformation matrix
  258. % Usage -- Mtrx
  259. /Mtrx 6 array def
  260.  
  261. % NF -- define new font
  262. % Usage -- /fontname NF
  263. /NF
  264. {
  265.   /newname exch def
  266.   newname 7 dict def
  267.   newname load
  268.   begin
  269.     /BitMaps 256 array def
  270.     /BuildChar { CharBuilder } def
  271.     /Encoding 256 array def
  272.     0 1 255 { Encoding exch /.notdef put } for
  273.     /FontBBox [ 0 0 1 1 ] def
  274.     /FontMatrix [ 1 0 0 1 0 0 ] def
  275.     /FontType 3 def
  276.   end
  277.   newname newname load definefont pop
  278. } bdf() pop
  279.  
  280. % NOTE -- note format page (increases available virtual memory from 240K
  281. %      to 340K on Apple LaserWriter)
  282. % Usage -- NOTE
  283. /NOTE
  284. {
  285.   note initmatrix
  286.   72 Resolution div dup scale           % set scaling to 1.
  287.   Mtrx currentmatrix pop
  288. } bdf
  289.  
  290. % P -- show string at current point, updating horizontal position to new endpt
  291. % Usage -- (string) P
  292. /P {show} bdf() pop
  293.  
  294. % Q -- draw bar of last size set by B command at specified point
  295. % Usage -- x y Q
  296. /Q {moveto w h B} bdf() pop
  297.  
  298. % R -- move relative right and show string, updating horizontal position to
  299. %      new endpoint
  300. % Usage -- (string) xxx R
  301. /R {0 rmoveto show} bdf() pop
  302.  
  303. % Resolution -- device resolution in dots/inch
  304. % Usage -- Resolution
  305. /Resolution 300 def
  306.  
  307. % S -- move absolute and show string, updating horizontal position to new endpt
  308. % Usage -- (string) xxx yyy S
  309. /S {moveto show} bdf() pop
  310.  
  311. % SF -- set new font at scale nnn (nnn = 1 normally; 2 gives double size chars)
  312. % Usage -- nnn /fontname SF
  313. /SF {findfont exch scalefont setfont} bdf() pop
  314.  
  315. % SNAP -- convert coordinates to integer device coordinates and back again
  316. % Usage -- xxx yyy SNAP (leave xxx' yyy' on stack)
  317. /SNAP {transform 2 {floor 0.5 add exch} repeat itransform} bdf
  318.  
  319. % T -- move absolute horizontally and show string, updating horizontal position
  320. % to new endpt
  321. % Usage -- (string) xxx T
  322. /T {currentpoint exch pop moveto show} bdf() pop
  323.  
  324. end                % TeXdict
  325. % the end the end the end the end the end the end the end the end the end
  326.