home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / share / elvis-2.2_0 / elvis.ps < prev    next >
Encoding:
Text File  |  2004-02-22  |  8.6 KB  |  241 lines

  1. % lib/elvis.ps
  2. %
  3. % This file is inserted into any PostScript generated by elvis.  It defines
  4. % the following symbols:
  5. %     ElvisN         push a 12-point normal font
  6. %     ElvisB         push a 12-point bold font
  7. %     ElvisI         push a 12-point italic font
  8. %     ElvisPage      translate & scale a page to fit the paper
  9. %     ElvisLeftPage  translate, rotate & scale to fit left half of paper
  10. %     ElvisRightPage translate, rotate & scale to fit right half of paper
  11. %     ElvisLeftEdge  CONSTANT offset to left edge of printable area
  12. %     ElvisTopEdge   CONSTANT offset to right edge of printable area
  13. %     ElvisWidth     CONSTANT width of printable area
  14. %     ElvisHeight    CONSTANT height of printable area
  15. %
  16. % In addition, elvis itself inserts some header information before this file,
  17. % in each PostScript output.  This includes the standard comments at the top
  18. % of the job, and also defines the following from elvis' options...
  19. %     ElvisPaper     CONSTANT name of the page size, such as (letter) or (a4)
  20. %     ElvisLines     CONSTANT lines per logical page
  21. %     ElvisColumns   CONSTANT columns per logical line
  22. %     ElvisBar          CONSTANT BOOL bar separating pages in two-up format
  23. %     ElvisFrame     CONSTANT BOOL frame around each page in two-up format
  24. %     ElvisPunch     CONSTANT BOOL increase left margin to leave room for a 3-hole punch
  25. %     ElvisClip      CONSTANT BOOL increase top margin for use with a clipboard
  26.  
  27. % Define the printing offsets.  These indicate where the *PRINTABLE* portion
  28. % of each page starts.  This is likely to vary from one printer to another.
  29. % The unit of measurement is a Point, approximately 1/72 of an inch.
  30. /ElvisLeftEdge 12 def
  31. /ElvisTopEdge 36 def
  32.  
  33. % Define the width and height of the printable area.  This will vary with
  34. % the type of paper.  The unit of measurement is a Point, ~ 1/72 of an inch.
  35. (letter) ElvisPaper eq {
  36.     /ElvisWidth 576 def
  37.     /ElvisHeight 720 def } if
  38. (legal) ElvisPaper eq {
  39.     /ElvisWidth 576 def
  40.     /ElvisHeight 936 def } if
  41. (executive) ElvisPaper eq {
  42.     /ElvisWidth 486 def
  43.     /ElvisHeight 634 def } if
  44. (a4) ElvisPaper eq {
  45.     /ElvisWidth 558 def
  46.     /ElvisHeight 770 def } if
  47. (a3) ElvisPaper eq {
  48.     /ElvisWidth 770 def
  49.     /ElvisHeight 1116 def } if
  50.  
  51. % Get the size of the print area, and its edge offsets
  52.  
  53.  
  54. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  55. %%%%%%%%%%                                                         %%%%%%%%%%%%
  56. %%%%%%%%%%  You probably won't need to modify anything after this  %%%%%%%%%%%%
  57. %%%%%%%%%%                                                         %%%%%%%%%%%%
  58. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  59.  
  60. % If ElvisWidth/ElvisHeight undefined, use default values
  61. true userdict { pop /ElvisWidth eq { pop false } if } forall {
  62.     /ElvisHSlop 24 def
  63.     /ElvisWSlop 9 def
  64.     clippath pathbbox 4 2 roll
  65.         /ElvisTopEdge exch ElvisHSlop add def
  66.         /ElvisLeftEdge exch ElvisWSlop add def
  67.         /ElvisHeight exch ElvisTopEdge sub ElvisHSlop 2 mul sub def
  68.         /ElvisWidth exch ElvisLeftEdge sub ElvisWSlop 2 mul sub def
  69.     newpath
  70. } if
  71.  
  72. % Adjust for punch
  73. ElvisPunch ElvisLeftEdge 60 le and {
  74.     userdict /ElvisWidth ElvisWidth ElvisLeftEdge add 60 sub put
  75.     userdict /ElvisLeftEdge 60 put
  76. } if
  77.  
  78. %Adjust for clipboard
  79. ElvisClip ElvisTopEdge 72 le and {
  80.     userdict /ElvisHeight ElvisHeight ElvisTopEdge add 72 sub put
  81.     userdict /ElvisTopEdge 72 put
  82. } if
  83.  
  84. % The virtual width/height varies with the number of rows/columns.  For
  85. % 80 columns by 60 rows, it is always 576 by 720 regardless of the paper size.
  86. /ElvisVWidth ElvisColumns 80 div 576 mul def
  87. /ElvisVHeight ElvisLines 60 div 720 mul def
  88.  
  89. % Compute the desired width of a string, instead of its actual width
  90. /ElvisStringWidth
  91. {
  92.     length ElvisColumns div ElvisVWidth mul
  93. } def
  94.  
  95. % Draw a string with the width that it would have if it was fixed-pitch.
  96. /ElvisShow
  97. {
  98.     % {string}
  99.  
  100.     % Push two copies of the string.
  101.     dup dup
  102.  
  103.     % {string string string}
  104.  
  105.     % Compute the scaling factors -- x=desired/normal, y=1.
  106.     ElvisStringWidth exch stringwidth pop div 1
  107.  
  108.     % {string xscale yscale}
  109.  
  110.     % Change scaling factor, but only temporarily. {string}
  111.     gsave scale
  112.  
  113.     % {string}
  114.  
  115.     % Draw the text {}
  116.     show
  117.  
  118.     % Restore the scaling factor, leaving the currentpoint after text. {}
  119.     currentpoint grestore moveto
  120. } def
  121.  
  122. % This array lists the shapes of every Latin-1 character.
  123. /Latin1
  124. [/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  125.  /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  126.  /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  127.  /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  128.  /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
  129.  /parenleft /parenright /asterisk /plus /comma /minus /period /slash
  130.  /zero /one /two /three /four /five /six /seven
  131.  /eight /nine /colon /semicolon /less /equal /greater /question
  132.  /at /A /B /C /D /E /F /G
  133.  /H /I /J /K /L /M /N /O
  134.  /P /Q /R /S /T /U /V /W
  135.  /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
  136.  /quoteleft /a /b /c /d /e /f /g
  137.  /h /i /j /k /l /m /n /o
  138.  /p /q /r /s /t /u /v /w
  139.  /x /y /z /braceleft /bar /braceright /asciitilde /space
  140.  /space /space /space /space /space /space /space /space
  141.  /space /space /space /space /space /space /space /space
  142.  /space /space /space /space /space /space /space /space
  143.  /space /space /space /space /space /space /space /space
  144.  /space /exclamdown /cent /sterling /currency /yen /brokenbar /section
  145.  /dieresis /copyright /ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron
  146.  /degree /plusminus /twosuperior /threesuperior /acute /mu /paragraph /periodcentered
  147.  /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf /threequarters /questiondown
  148.  /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
  149.  /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis
  150.  /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply
  151.  /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls
  152.  /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla
  153.  /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icurcumflex /idieresis
  154.  /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide
  155.  /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] def
  156.  
  157. % This procedure is passed two names - The name of a new font to create, and
  158. % the name of an existing font to create it from.  Upon completion, the
  159. % args have been removed from the stack and the new font is defined.  The
  160. % only difference between the two is that the new font uses the Latin-1
  161. % encoding.
  162. /DoTheLatinShuffle
  163. {
  164.     findfont
  165.     dup maxlength dict /Temp exch def
  166.     { exch dup dup /FID ne exch /UniqueID ne and
  167.         { exch Temp 3 1 roll put }
  168.         { pop pop }
  169.         ifelse
  170.     } forall
  171.     Temp dup /Encoding Latin1 put
  172.     definefont pop
  173. } def
  174.  
  175. % Derive 3 Latin-1 fonts from the existing fonts
  176. /Elvis-Normal /Courier DoTheLatinShuffle
  177. /Elvis-Bold /Courier-Bold DoTheLatinShuffle
  178. /Elvis-Italic /Courier-Oblique DoTheLatinShuffle
  179. /Elvis-Proportional-Normal /Times-Roman DoTheLatinShuffle
  180. /Elvis-Proportional-Bold /Times-Bold DoTheLatinShuffle
  181. /Elvis-Proportional-Italic /Times-Italic DoTheLatinShuffle
  182.  
  183. % Define symbolic names for the 12-point versions of those fonts
  184. /ElvisN /Elvis-Normal findfont 12 scalefont def
  185. /ElvisB /Elvis-Bold findfont 12 scalefont def
  186. /ElvisI /Elvis-Italic findfont 12 scalefont def
  187. /ElvisPN /Elvis-Proportional-Normal findfont 12 scalefont def
  188. /ElvisPB /Elvis-Proportional-Bold findfont 12 scalefont def
  189. /ElvisPI /Elvis-Proportional-Italic findfont 12 scalefont def
  190.  
  191. % Define the page-scaling functions
  192. /ElvisPage
  193. {
  194.     ElvisLeftEdge ElvisTopEdge translate
  195.     ElvisWidth ElvisVWidth div ElvisHeight ElvisVHeight div scale
  196. } def
  197. /ElvisLeftPage
  198. {
  199.     ElvisLeftEdge ElvisWidth add ElvisTopEdge translate
  200.     90 rotate
  201.     ElvisHeight ElvisVWidth 2 mul div ElvisWidth ElvisVHeight div scale
  202.     ElvisWidth 0.02 mul ElvisHeight 0.02 mul translate 0.94 0.96 scale
  203.  
  204.     0 setlinewidth
  205.  
  206.     % Draw a frame around page
  207.     ElvisFrame {
  208.         -5 -5 moveto
  209.         ElvisVWidth 10 add 0 rlineto
  210.         0 ElvisVHeight 10 add rlineto
  211.         ElvisVWidth 10 add neg 0 rlineto
  212.         closepath stroke
  213.     } if
  214. } def
  215. /ElvisRightPage
  216. {
  217.     % Draw a line between left & right pages
  218.     ElvisBar {
  219.         newpath
  220.         ElvisLeftEdge ElvisTopEdge ElvisHeight 2 div add moveto
  221.         ElvisWidth 0 rlineto
  222.         stroke
  223.     } if
  224.  
  225.     ElvisLeftEdge ElvisWidth add ElvisTopEdge ElvisHeight 2 div add translate
  226.     90 rotate
  227.     ElvisHeight ElvisVWidth 2 mul div ElvisWidth ElvisVHeight div scale
  228.     ElvisWidth 0.04 mul ElvisHeight 0.02 mul translate 0.94 0.96 scale
  229.  
  230.     0 setlinewidth
  231.  
  232.     % Draw a frame around page
  233.     ElvisFrame {
  234.         -5 -5 moveto
  235.         ElvisVWidth 10 add 0 rlineto
  236.         0 ElvisVHeight 10 add rlineto
  237.         ElvisVWidth 10 add neg 0 rlineto
  238.         closepath stroke
  239.     } if
  240. } def
  241.