home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / CHIPCD_3_98.iso / software / testsoft / global / pdxrun.exe / PDOXPORT.PS < prev    next >
Text File  |  1993-01-25  |  18KB  |  528 lines

  1. %!
  2. % Copyright (c) 1985, Adobe Systems Incorporated, Palo Alto, CA.
  3. % "Used with permission."
  4. % This program may be reproduced, used, and sold, as long as the above
  5. % copyright notice appears in all copies (in any media) and on labels of
  6. % machine-readable media.
  7. % Definitions for program "Daisyprint".
  8. % Last revision: MJF Tue Apr 22 11:40:34 1986
  9. % ADOBE FORUM DL4   PS-DEM.TXT  10/7/87
  10.  
  11. % Modifications Copyright (c) 1991, Borland International
  12. % "Used with permission."
  13.  
  14. % Revised for Borland: MTA 8/9/91
  15.  
  16. % The following section allows Daisyprint to be downloaded "persistently",
  17. % i.e., remaining in the printer until it is turned off, instead of
  18. % disappearing at the end of the job.
  19. % Default behavior is to be NON-persistent.
  20.  
  21. /persistent? false def       % Change this if you want.
  22. /passwd 0 def                % The sysmgr may change this.
  23. persistent? {
  24.     /Courier findfont 10 scalefont setfont
  25.     /Daisyprint where
  26.     { pop (Emulator in place - not loaded again) 100 100 moveto
  27.         show showpage stop }
  28.     { serverdict begin statusdict begin passwd checkpassword
  29.     { (Emulator downloaded.)100 100 moveto show showpage
  30.         passwd exitserver }
  31.     { (Bad Password on loading emulator!!!)100 100 moveto show
  32.         showpage stop }
  33.     ifelse }
  34.     ifelse
  35. } if
  36.  
  37. % Generic daisy-wheel emulator. Current parameters are set up for Vanilla.
  38. % None of the following defs should be changed.  Procs and defs that can
  39. % be safely changed are those in the second half of this program,
  40. % following the second double bar line.  Instructions for use are at the
  41. % end of this listing.
  42. % ========================================================================
  43.  
  44. /DaisyEmDict 50 dict def
  45. /Daisyprint  {DaisyEmDict begin printfile end} def
  46.  
  47. DaisyEmDict begin
  48. % ---------
  49.  
  50. /printfile             % Main job loop
  51.   { reentry? not{ initjob }if
  52.     /CmdDictBase countdictstack 1 add def
  53.     CmdDict begin
  54.     {currentfile read  % Read one byte at a time.
  55.                        % Be sure not to send ^c,^d,^t,^s,^q.
  56.       {printchar}{showpage terminate} ifelse
  57.     }loop
  58.     popCmdStack end    % CmdDict
  59.   }def
  60.  
  61. /initjob
  62.   {  RomanFont setfont
  63.      /linect 1 def
  64.      /charct 0 def
  65.      initpage
  66.   }def
  67.  
  68. /initpage
  69.   { orientpage
  70.     LeftMargin FirstLine moveto
  71.     /linect 1 store
  72.     /charct 0 store
  73.   }def
  74. % Caution - This program stacks dictionaries.  It is therefore wise to use
  75. % "store" rather than "def" to assign new values to old variables.
  76.  
  77. /printchar    % ( n  --  )   This routine actually does the emulation.
  78.   { dup cmd?
  79.       {doCmd}{emit}ifelse
  80.   }def
  81.  
  82. /cmd?         % ( n -- b )    Looks for command only in topmost dictionary
  83.   { currentdict exch known }def
  84.  
  85. /doCmd        % As per the topmost dictionary, since doCmd is only invoked
  86.               % if cmd? finds the command in the topmost dict.
  87.               % default top dict:  CmdDict
  88.  
  89.   {load exec} def
  90.  
  91. /emit    % ( n --  )    convert char code to printable char, and show it.
  92.   { charct MaxCharCt  ge
  93.       { CR LF }if
  94.     workstring  dup 0 4 -1 roll put show
  95.     /charct charct 1 add store
  96.   }def
  97.  
  98. /CmdError   % To handle errors during multi-character command sequences,
  99.             % "emit" is redefined, thanks to dictionary stacking and
  100.             % late-binding.  See /EscDict later on in this listing.
  101.  
  102.   { popCmdStack printchar }def
  103.  
  104. /popCmdStack   % Clean up dict stack after completion or interruption of
  105.                % multi-character command sequences.
  106.                % CmdDictBase was defined in initjob.
  107.                % CmdDict is never popped off the dict stack.
  108.  
  109.   { countdictstack CmdDictBase sub  {end}  repeat }def
  110.  
  111. /terminate { /reentry? false store exit }def
  112.                         % Exits the printfile job loop.
  113.                         % Does not print the current page.
  114.  
  115. /interrupt { /reentry? true store exit }def
  116.                         % Same as 'terminate', but sets flag
  117.                         % for potential reentry.  Flag is used
  118.                         % at beginning of 'printfile' to prevent
  119.                         % job and page initialization.
  120.  
  121. /reentry?  false def    % Initialize within DaisyEmDict
  122.  
  123. % Routines to assist page handling
  124. % --------
  125.  
  126. /orientpage
  127.   { setlandscape?
  128.       { 8.5 72 mul 0 translate 90 rotate }
  129.       {}
  130.     ifelse
  131.   }def
  132.  
  133. /workstring 1 string def
  134.  
  135. /CR    % cr only (no linefeed)
  136.  
  137.   { LeftMargin currentpoint exch pop moveto
  138.     /charct 0 store
  139.   }def
  140.  
  141. /LF                           % Linefeed without cr  --  ff if needed.
  142.                               % Linect was def'ed in initjob.
  143.  
  144.   { linect MaxLineCt  lt
  145.       { /linect linect 1 add store
  146.         currentpoint LnHt sub moveto }
  147.       { currentpoint pop FirstLine
  148.         FF  moveto }
  149.       ifelse
  150.   }def
  151.  
  152. /FF                           % showpage and formfeed
  153.  
  154.   { showpage initpage }def
  155.  
  156. %% utility to re-encode a PostScript font producing a
  157. %% new font given a base font name, new font name, and
  158. %% encoding vector on the stack:
  159.  
  160. /encodefont
  161. {
  162.     0 begin                    % local storage placeholder
  163.  
  164.     /encodevect exch def            % new encoding vector
  165.     /newfontname exch def            % new font name
  166.     /basefontname exch def            % base font name
  167.  
  168.     /basefont basefontname findfont def
  169.     /newfont basefont maxlength dict def
  170.  
  171.     basefont {
  172.     exch
  173.     dup dup /FID ne exch /Encoding ne and    % don't copy FID or Encoding
  174.     { exch newfont 3 1 roll put }
  175.     { pop pop }
  176.     ifelse
  177.     } forall
  178.  
  179.     newfont /FontName newfontname put
  180.     newfont /Encoding encodevect put
  181.     newfontname newfont definefont pop
  182.  
  183.     end                        % encodedict
  184. } def
  185.  
  186. /encodefont load 0 5 dict put            % provide local storage
  187.  
  188. %% create an encoding vector for the IBM PC code page 437
  189. %% symbol set.  Not all symbols are available in an Adobe Type 1
  190. %% font--we map those that are and leave the others undefined.
  191. %% We start by initializing the encoding vector and copying the
  192. %% ASCII portion of the standard encoding:
  193.  
  194. /ibm437vect 256 array def
  195.   0 1  31 { ibm437vect exch /.notdef put } for
  196.  32 1 127 { dup StandardEncoding exch get ibm437vect 3 1 roll put } for
  197. 128 1 255 { ibm437vect exch /.notdef put } for
  198.  
  199. ibm437vect
  200.  % dup 16#01 /.notdef        put    % "white face"
  201.  % dup 16#02 /.notdef        put    % "black face"
  202.  % dup 16#03 /.notdef        put    % heart
  203.  % dup 16#04 /.notdef        put    % diamond
  204.  % dup 16#05 /.notdef        put    % club
  205.  % dup 16#06 /.notdef        put    % spade
  206.  dup 16#07 /bullet        put    % bullet
  207.  % dup 16#08 /.notdef        put    % "square hole"
  208.  % dup 16#09 /.notdef        put    % "ring"
  209.  % dup 16#0a /.notdef        put    % "square ring"
  210.  % dup 16#0b /.notdef        put    % "male symbol"
  211.  % dup 16#0c /.notdef        put    % "female symbol"
  212.  % dup 16#0d /.notdef        put    % "note"
  213.  % dup 16#0e /.notdef        put    % "double note"
  214.  dup 16#0f /currency        put    % 
  215.  % dup 16#10 /.notdef        put    % "right caret"
  216.  % dup 16#11 /.notdef        put    % "left caret"
  217.  % dup 16#12 /.notdef        put    % "up/down arrow"
  218.  % dup 16#13 /.notdef        put    % "double exclaim"
  219.  dup 16#14 /paragraph        put    % 
  220.  dup 16#15 /section        put    % 
  221.  % dup 16#16 /.notdef        put    % "bar"
  222.  % dup 16#17 /.notdef        put    % "up/down arrow w/underbar"
  223.  % dup 16#18 /.notdef        put    % arrowup
  224.  % dup 16#19 /.notdef        put    % arrowdown
  225.  % dup 16#1a /.notdef        put    % arrowright
  226.  % dup 16#1b /.notdef        put    % arrowleft
  227.  % dup 16#1c /.notdef        put    % "inverted not symbol"
  228.  % dup 16#1d /.notdef        put    % arrowboth
  229.  % dup 16#1e /.notdef        put    % "up caret"
  230.  % dup 16#1f /.notdef        put    % "down caret"
  231.  
  232.  dup 16#80 /Ccedilla        put    % 
  233.  dup 16#81 /udieresis        put    % 
  234.  dup 16#82 /eacute        put    % 
  235.  dup 16#83 /acircumflex        put    % 
  236.  dup 16#84 /adieresis        put    % 
  237.  dup 16#85 /agrave        put    % 
  238.  dup 16#86 /aring        put    % 
  239.  dup 16#87 /ccedilla        put    % 
  240.  dup 16#88 /ecircumflex        put    % 
  241.  dup 16#89 /edieresis        put    % 
  242.  dup 16#8a /egrave        put    % 
  243.  dup 16#8b /idieresis        put    % 
  244.  dup 16#8c /icircumflex        put    % 
  245.  dup 16#8d /igrave        put    % 
  246.  dup 16#8e /Adieresis        put    % 
  247.  dup 16#8f /Aring        put    % 
  248.  dup 16#90 /Eacute        put    % 
  249.  dup 16#91 /ae            put    % 
  250.  dup 16#92 /AE            put    % 
  251.  dup 16#93 /ocircumflex        put    % 
  252.  dup 16#94 /odieresis        put    % 
  253.  dup 16#95 /ograve        put    % 
  254.  dup 16#96 /ucircumflex        put    % 
  255.  dup 16#97 /ugrave        put    % 
  256.  dup 16#98 /ydieresis        put    % 
  257.  dup 16#99 /Odieresis        put    % 
  258.  dup 16#9a /Udieresis        put    % 
  259.  dup 16#9b /cent        put    % 
  260.  dup 16#9c /sterling        put    % 
  261.  dup 16#9d /yen            put    % 
  262.  % dup 16#9e /.notdef        put    % "printers point"
  263.  dup 16#9f /florin        put    % 
  264.  dup 16#a0 /aacute        put    % 
  265.  dup 16#a1 /iacute        put    % 
  266.  dup 16#a2 /oacute        put    % 
  267.  dup 16#a3 /uacute        put    % 
  268.  dup 16#a4 /ntilde        put    % 
  269.  dup 16#a5 /Ntilde        put    % 
  270.  dup 16#a6 /ordfeminine        put    % 
  271.  dup 16#a7 /ordmasculine    put    % 
  272.  dup 16#a8 /questiondown    put    % 
  273.  % dup 16#a9 /.notdef        put    % "reversed logical not"
  274.  dup 16#aa /logicalnot        put    % 
  275.  dup 16#ab /onehalf        put    % 
  276.  dup 16#ac /onequarter        put    % 
  277.  dup 16#ad /exclamdown        put    % 
  278.  dup 16#ae /guillemotleft    put    % 
  279.  dup 16#af /guillemotright    put    % 
  280.  % dup 16#b0 /.notdef        put    % "25% gray screen"
  281.  % dup 16#b1 /.notdef        put    % "50% gray screen"
  282.  % dup 16#b2 /.notdef        put    % "75% gray screen"
  283.  
  284.  % dup 16#b3 /.notdef        put    % "Line Drawing Symbols b3-da"
  285.  % dup 16#b4 /.notdef        put    % 
  286.  % dup 16#b5 /.notdef        put    % 
  287.  % dup 16#b6 /.notdef        put    % 
  288.  % dup 16#b7 /.notdef        put    % 
  289.  % dup 16#b8 /.notdef        put    % 
  290.  % dup 16#b9 /.notdef        put    % 
  291.  % dup 16#ba /.notdef        put    % 
  292.  % dup 16#bb /.notdef        put    % 
  293.  % dup 16#bc /.notdef        put    % 
  294.  % dup 16#bd /.notdef        put    % 
  295.  % dup 16#be /.notdef        put    % 
  296.  % dup 16#bf /.notdef        put    % 
  297.  % dup 16#c0 /.notdef        put    % 
  298.  % dup 16#c1 /.notdef        put    % 
  299.  % dup 16#c2 /.notdef        put    % 
  300.  % dup 16#c3 /.notdef        put    % 
  301.  % dup 16#c4 /.notdef        put    % 
  302.  % dup 16#c5 /.notdef        put    % 
  303.  % dup 16#c6 /.notdef        put    % 
  304.  % dup 16#c7 /.notdef        put    % 
  305.  % dup 16#c8 /.notdef        put    % 
  306.  % dup 16#c9 /.notdef        put    % 
  307.  % dup 16#ca /.notdef        put    % 
  308.  % dup 16#cb /.notdef        put    % 
  309.  % dup 16#cc /.notdef        put    % 
  310.  % dup 16#cd /.notdef        put    % 
  311.  % dup 16#ce /.notdef        put    % 
  312.  % dup 16#cf /.notdef        put    % 
  313.  % dup 16#d0 /.notdef        put    % 
  314.  % dup 16#d1 /.notdef        put    % 
  315.  % dup 16#d2 /.notdef        put    % 
  316.  % dup 16#d3 /.notdef        put    % 
  317.  % dup 16#d4 /.notdef        put    % 
  318.  % dup 16#d5 /.notdef        put    % 
  319.  % dup 16#d6 /.notdef        put    % 
  320.  % dup 16#d7 /.notdef        put    % 
  321.  % dup 16#d8 /.notdef        put    % 
  322.  % dup 16#d9 /.notdef        put    % 
  323.  % dup 16#da /.notdef        put    % 
  324.  
  325.  % dup 16#db /.notdef        put    % "full cell tile -- 100% grey screen"
  326.  % dup 16#dc /.notdef        put    % "top half tile"
  327.  % dup 16#dd /.notdef        put    % "left half tile"
  328.  % dup 16#de /.notdef        put    % "right half tile"
  329.  % dup 16#df /.notdef        put    % "bottom half tile"
  330.  
  331.  % dup 16#e0 /.notdef        put    % alpha
  332.  % dup 16#e1 /.notdef        put    % beta
  333.  % dup 16#e2 /.notdef        put    % Gamma
  334.  % dup 16#e3 /.notdef        put    % pi
  335.  % dup 16#e4 /.notdef        put    % Sigma
  336.  % dup 16#e5 /.notdef        put    % sigma
  337.  % dup 16#e6 /.notdef        put    % mu
  338.  % dup 16#e7 /.notdef        put    % tao
  339.  % dup 16#e8 /.notdef        put    % Phi
  340.  % dup 16#e9 /.notdef        put    % theta
  341.  % dup 16#ea /.notdef        put    % Omega
  342.  % dup 16#eb /.notdef        put    % delta
  343.  % dup 16#ec /.notdef        put    % infinity
  344.  % dup 16#ed /.notdef        put    % emptyset
  345.  % dup 16#ee /.notdef        put    % epsilon
  346.  % dup 16#ef /.notdef        put    % intersection
  347.  % dup 16#f0 /.notdef        put    % equivalence
  348.  % dup 16#f1 /.notdef        put    % plusminus
  349.  % dup 16#f2 /.notdef        put    % greaterequal
  350.  % dup 16#f3 /.notdef        put    % lessequal
  351.  % dup 16#f4 /.notdef        put    % integraltp
  352.  % dup 16#f5 /.notdef        put    % integralbt
  353.  % dup 16#f6 /.notdef        put    % divide
  354.  % dup 16#f7 /.notdef        put    % approxequal
  355.  dup 16#f8 /degree        put    %
  356.  % dup 16#f9 /.notdef        put    % "small bullet"
  357.  % dup 16#fa /.notdef        put    % dotmath
  358.  % dup 16#fb /.notdef        put    % radical
  359.  % dup 16#fc /.notdef        put    % eta
  360.  dup 16#fd /twosuperior        put    %
  361.  % dup 16#fe /.notdef        put    % "square bullet"
  362.  % dup 16#ff /.notdef        put    % 
  363. pop
  364.  
  365. %% create a Nordic encoding based on the standard
  366. %% IBM PC encoding:
  367.  
  368. /ibm865vect 256 array def
  369. 0 1 255 { dup ibm437vect exch get ibm865vect 3 1 roll put } for
  370.  
  371. ibm865vect
  372.  dup 16#9b /oslash        put    % 
  373.  dup 16#9d /Oslash        put    % 
  374.  dup 16#af /currency        put    % 
  375.  
  376. %% save the encoding vectors in a dictionary keyed by their
  377. %% code page number:
  378.  
  379. /CodePageEncoding 2 dict def
  380.   CodePageEncoding 437 ibm437vect put
  381.   CodePageEncoding 865 ibm865vect put
  382.  
  383. %% =====================================================================
  384. %% Parameters and procedures defined after this point may be customized
  385. %% without harm (?) to the program.
  386.  
  387. /setlandscape?  false  def
  388.  
  389. /RomanFontName  /Courier         def        % names of the three base fonts
  390. /BoldFontName   /Courier-Bold    def
  391. /ItalicFontName /Courier-Oblique def
  392.  
  393. /CodePage   437  def                        % IBM PC code page (set to 0 to
  394.                                             % disable re-encoding of fonts)
  395.  
  396. /TopOfPage   10.50 72 mul def
  397. /LeftMargin   0.25 72 mul def
  398. /fsize       11           def               % font size (in points)
  399. /LnHt        11           def               % line leading (in points)
  400. /MaxLineCt   66           def               % lines per page
  401. /MaxCharCt   80           def               % characters per line
  402.  
  403. /FirstLine   TopOfPage fsize sub  def
  404.  
  405.  
  406. %% Produce roman, bold, and italic fonts.  First retrieve the proper
  407. %% encoding vector and re-encode the base fonts.  If code page is not
  408. %% supported, simply use the base fonts without reencoding.  Finally,
  409. %% find and scale the fonts:
  410.  
  411. CodePageEncoding CodePage known
  412.     {
  413.     %% If code page is defined in the code page encoding dictionary,
  414.     %% re-encode the three base fonts to produce the working fonts:
  415.  
  416.     /eVect CodePageEncoding CodePage get  def
  417.  
  418.     RomanFontName   /PDOXIBM        eVect  encodefont
  419.     BoldFontName    /PDOXIBM-Bold   eVect  encodefont
  420.     ItalicFontName  /PDOXIBM-Italic eVect  encodefont
  421.  
  422.     /RomanFontName  /PDOXIBM         def
  423.     /BoldFontName   /PDOXIBM-Bold    def
  424.     /ItalicFontName /PDOXIBM-Italic  def
  425.     }
  426.     if
  427.  
  428. /RomanFont   RomanFontName   findfont fsize scalefont  def
  429. /BoldFont    BoldFontName    findfont fsize scalefont  def
  430. /ItalicFont  ItalicFontName  findfont fsize scalefont  def
  431.  
  432. %% Horizontal tab -- typical implementation,
  433. %% tabs set every 8 spaces, fixed:
  434.  
  435. /HT {
  436.     8 charct 8 mod sub
  437.     { 32 emit }
  438.     repeat
  439.     } def
  440.  
  441. % ------------
  442. % The following parameters define CmdDict and its sub-dictionaries.
  443. % They can be customized to any extent.
  444.  
  445. /CmdDict  30 dict  def   % May need to be enlarged if you add a lot to it.
  446. CmdDict begin            % Store the defs in CmdDict, rather than clutter
  447.                          % DaisyEmDict with all this stuff.
  448.  
  449.  12  {FF} def
  450.   9  {HT} def
  451.  
  452.  10  {CR LF} def    % Note:  The serial ports in pure PostScript printers
  453.             % have a "feature" at this time which forces all
  454.             % Linefeeds, CR-LF pairs, and CR's to appear as simple
  455.             % LF's to the "read" operator.  The HP LJ PostScript
  456.             % Cartridge relies on the LJ processor for
  457.             % communications and doesn't seem to have this
  458.             % problem.  The HP cartridge therefore "sees" CR's
  459.             % while other PS printers don't.
  460.  
  461.  13  {CR} def       % Carriage return (see note above)
  462.  
  463.  26  {interrupt} def      % ^Z will terminate emulation w/o ending the job
  464.                           % (and without printing the current page).
  465.                           % This may be useful for inserting
  466.                           % PostScript illustrations, etc.
  467.  
  468.  27  {ESC} def
  469.  
  470. /EscDict  10 dict def    % May need to be enlarged if you add a lot to it.
  471.  
  472. /ESC                     % Handle two-character "escape" sequences.
  473.   { EscDict begin }def
  474.  
  475. % Rules for creating Command sub-dictionaries:
  476. % Sub-dictionaries of CmdDict may be nested to handle multi-character
  477. % command sequences of arbitrary length.  EscDict is an example, which
  478. % handles 2-char sequences beginning with "escape".  Note that EscDict
  479. % is created entirely within the dictionary (CmdDict) which may invoke it.
  480. % Each sub-dictionary must contain the re-definition of "emit" shown
  481. % below. This takes care of invoking popCmdStack when a multi-char command
  482. % becomes unrecognizable in the middle of the sequence.  That's all the
  483. % error-handling there is, folks!
  484. % Each leaf in any command sub-dictionary (i.e., the procedure def for
  485. % any command character that ends a command sequence) must end with
  486. % an invocation of popCmdStack.
  487. % That probably isn't clear, so please observe the use of "popCmdStack"
  488. % in the following defs, and do likewise!
  489. % Defs that do NOT need to popCmdStack:
  490. % -- words like ESC which are not "leafs" because they lead on to
  491. % further sub-dict nesting.
  492. % -- words in the root command dict, "CmdDict".
  493.  
  494.  
  495. EscDict begin
  496. % -----------
  497.  
  498.     /emit  { CmdError }def
  499.     34  { RomanFont setfont popCmdStack }def
  500.     33  { BoldFont  setfont popCmdStack }def
  501.     88  { ItalicFont setfont popCmdStack }def
  502.     89  { RomanFont setfont popCmdStack }def
  503.  
  504. end  % EscDict
  505. % -------------
  506.  
  507.  
  508.  
  509. end  % CmdDict
  510. end  % DaisyEmDict    % End of program "Daisyprint".
  511.  
  512. % ******** ADDITIONAL NOTES ********
  513.  
  514. % Proper format for use:
  515. %
  516. %  Daisyprint CR
  517. %  data data data data .....
  518. %  ...data data  ^D
  519. %
  520. % Emulation can also be interrupted with a ^Z.  In this case
  521. % the printer will revert to PostScript mode without ending the
  522. % current job.  This could be useful for including diagrams,
  523. % etc.  Emulation can be reinvoked just by saying "Daisyprint"
  524. % again.  For further info, see definitions of 'terminate',
  525. % 'interrupt', and code 26 in CmdDict.
  526.  
  527. Daisyprint
  528.