home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / laser / postprn.arc / SHOWLINE.PS < prev   
Text File  |  1989-06-09  |  3KB  |  128 lines

  1. %!
  2. % showline -- display the top line on the stack.
  3. %
  4. % assumes we have access to:
  5. %
  6. %        doFF            handle a form-feed (2 arguments)
  7. %        /x                current x location
  8. %        /y                current y location
  9. %        /normal-font    regular, unbolded font
  10. %        /bold-font        bolded version of /normal
  11. %        /italic-font    italics version of /normal
  12. %        /page_text        set to 1 if text on this page, 0 otherwise
  13. %
  14.  
  15.  
  16. /underline 0 def
  17.  
  18. /showline
  19. {
  20. %
  21. % We have a string -- look for any special characters.
  22. %
  23.     /spec 0 def
  24.     dup
  25.     {
  26.         32 lt
  27.         {
  28.             /spec 1 def
  29.             exit
  30.         } if
  31.     } forall
  32. %
  33. % If no special characters, just show the line
  34. %
  35.     spec 0 eq
  36.     {
  37.         x y moveto
  38.         show
  39.         /page_text 1 def
  40.     }
  41. %
  42. % Special characters -- do it the hard way, char by char.
  43. %
  44.     {
  45.         {
  46.             dup 32 lt
  47.             {
  48.                 dup 28 lt                    % If char not FS..US
  49.                 {
  50.                     dup 12 eq                % If char is a FF
  51.                     {
  52.                         pop
  53.                         0 1 doFF            % Let doFF do it all
  54.                     }
  55.                     {
  56.                         8 eq            % If char is a BS
  57.                         {
  58.                             /x x xw sub def    % Just decrement x
  59.                             /y y yw sub def    % Just decrement y
  60.                             x y moveto
  61.                         } if
  62.                     } ifelse
  63.                 }
  64.                 {                            % This is a FS..US
  65.                     dup 31 eq
  66.                     {                        % US - turns off
  67.                         pop
  68.                         normal-font setfont    % Return to normal font
  69.                         /underline 0 def    % Turn off underlining
  70.                         /isbold 0 def        % Remember not bold mode
  71.                         /isitalic 0 def        % Remember not italics mode
  72.                     }
  73.                     {                        % turn bold, under or italics on
  74.                         dup 30 eq
  75.                         {                    % - turns on bolding
  76.                             pop
  77.                             isitalic 0 eq
  78.                             {
  79.                                 bold-font setfont
  80.                             }
  81.                             {
  82.                                 bolditalic-font setfont
  83.                             } ifelse
  84.                             /isbold 1 def    % Remember bold mode
  85.                         }
  86.                         {
  87.                             29 eq
  88.                             {                % -- turn on underscoring
  89.                                 /underline 1 def
  90.                             }
  91.                             {                % -- turn on italics
  92.                                 /isitalic 1 def    % Remember italics mode
  93.                                 isbold 0 eq
  94.                                 {
  95.                                     italic-font setfont
  96.                                 }
  97.                                 {
  98.                                     bolditalic-font setfont
  99.                                 } ifelse
  100.                             } ifelse
  101.                         } ifelse
  102.                     } ifelse
  103.                 } ifelse
  104.             }
  105. %
  106. % Otherwise -- character is printable
  107. %
  108.             {
  109.                 ones 0 3 -1 roll put    % Make our substring
  110.                 x y moveto
  111.                 underline 1 eq
  112.                 {
  113.                     ones undershow        % Show the string
  114.                 }
  115.                 {
  116.                     ones show            % Show the string
  117.                 } ifelse
  118.                 /xw                        % Prepare to update xw
  119.                 ones stringwidth        % new xw and yw now on stack
  120.                 /yw exch def def        % defines new xw and yw
  121.                 /x x xw add def            % Increment x
  122.                 /y y yw add def            % Increment y
  123.                 /page_text 1 def
  124.             } ifelse
  125.         } forall
  126.     } ifelse
  127. } def
  128.