home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / ghostscript / 8.64 / lib / dmp_init.ps < prev    next >
Encoding:
Text File  |  2009-04-17  |  7.1 KB  |  207 lines

  1. %!
  2. %    Copyright (C) 1989, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  3. %
  4. % This file is part of Ghostscript.
  5. %
  6. % Ghostscript is distributed in the hope that it will be useful, but
  7. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. % to anyone for the consequences of using it or for whether it serves any
  9. % particular purpose or works at all, unless he says so in writing.  Refer
  10. % to the Ghostscript General Public License for full details.
  11. %
  12. % Everyone is granted permission to copy, modify and redistribute
  13. % Ghostscript, but only under the conditions described in the Ghostscript
  14. % General Public License.  A copy of this license is supposed to have been
  15. % given to you along with Ghostscript so you can know your rights and
  16. % responsibilities.  It should be in a file named COPYING.  Among other
  17. % things, the copyright notice and this notice must be preserved on all
  18. % copies.
  19.  
  20. % dmp_init.ps
  21. %   Initialization file for `dmprt' device driver.
  22. %
  23. %   Written initial version by...         ASAYAMA Kazunori  1993 Nov.
  24. %   Modified for Ghostscript 4.03 by ...  ASAYAMA Kazunori  1997 May.
  25.  
  26. %%%%%                        check version                         %%%%%
  27.  
  28. 201 % version of this initialization file.
  29.  
  30. /dmprt finddevice { /DmprtParams gsgetdeviceprop /Version get }
  31.   stopped { pop pop 0 } if
  32. 2 copy ne {
  33.   (\ndmprt: driver version\() print
  34.   dup 0 eq {pop (unknown) print }{==only}ifelse
  35.   (\) does not match dmp_init.ps version\() print
  36.   ==only (\).\n) print
  37.   flush 1 .quit
  38. } { pop pop } ifelse
  39.  
  40. %%%%%                            BODY                              %%%%%
  41.  
  42. 40 dict begin         % .WorkDict .UserParams
  43.                       % .DmprtDevice
  44.                       % .GetDmprtParam .SetDmprtParam
  45.                       % .DmprtParams .Xdpi .Ydpi .Xdot .Ydot
  46.                       %
  47.                       % in cm mm pt bp dot
  48.                       % BeginMode EndMode
  49.                       % .ModeDataBase .CurrentMode
  50.                       % BeginConfig EndConfig
  51.                       % BeginPrinterProps EndPrinterProps
  52.  
  53. /.WorkDict currentdict def
  54. /.ModeDataBase 10 dict def
  55. /.dicttomark {
  56.   counttomark 2 idiv dup dict begin { def } repeat pop currentdict end
  57. } bind def
  58.  
  59. %%%%%                utilities for user customization.             %%%%%
  60.  
  61. /in { } bind def
  62. /cm { 2.54 div } bind def
  63. /mm { 25.4 div } bind def
  64. /pt { 72.27 div } bind def
  65. /bp { 72.0 div } bind def
  66. /dot { [ exch truncate cvi ] } bind def
  67.  
  68. % the database of user customizations. (not implemented yet.)
  69. /BeginMode { % <name> -> <name> mark
  70.   mark
  71. } bind def
  72. /EndMode { % <name> mark <item1> <value1> ... <itemN> <valueN> -> --
  73.   .dicttomark .ModeDataBase
  74.   dup dup maxlength exch length eq {
  75.     % Expand capacity of database dictionaly.
  76.     dup maxlength 10 add dict copy dup /.ModeDataBase exch def
  77.   } if
  78.   3 1 roll put
  79. } bind def
  80.  
  81. % these procedures are undocumented in the user's manual.
  82. % these are used in order to specify the propaties directly.
  83. /BeginPrinterProps { [ } bind def
  84. /EndPrinterProps { ] /printer exch } bind def
  85.  
  86. %%%%%                run the user customization file.              %%%%%
  87.  
  88. /BeginConfig mark def
  89. /EndConfig { .dicttomark /.UserParams exch def } bind def
  90. systemdict /DMPCONFIG 2 copy known
  91. { get run }    % -sDMPCONFIG=<filename>
  92. { pop pop (dmp_site.ps) findlibfile { closefile run } if } ifelse
  93.  
  94. %%%%%                        refer database                        %%%%%
  95.  
  96. /.UsedMode .ModeDataBase length dict def
  97. /.ExpandUserParams { % <dict> -> <param1> <value1> ... <paramN> <valueN>
  98.   /.InheritMode null def
  99.   { 1 index /inherit eq {
  100.       exch pop dup .UsedMode exch known { % check recursive reference.
  101.         /.ExpandUserParams /rangecheck signalerror
  102.       } if
  103.       /.InheritMode exch def
  104.     } if } forall
  105.   .InheritMode type /nametype eq {
  106.     .UsedMode .InheritMode true put
  107.     .ModeDataBase .InheritMode get .ExpandUserParams
  108.   } if
  109. } bind def
  110.  
  111. systemdict /DMPMODE 2 copy known
  112.   {get .ModeDataBase exch get} {pop pop .UserParams} ifelse
  113. mark exch .ExpandUserParams .dicttomark /.UserParams exch def
  114.  
  115. %%%%%                Local variables and procedures.               %%%%%
  116. /.DmprtDevice /dmprt finddevice def
  117. /.SetDmprtParam {   % <key> <value> -> --
  118.   .DmprtParams 3 1 roll put
  119. } bind def
  120. /.SetLocalParam { .LocalParams 3 1 roll put } bind def
  121. /.GetDmprtParam {   % <key> -> <value>
  122.   .DmprtParams exch get
  123. } bind def
  124. /.GetUserParam {       % <key> <default-value> -> <value>
  125.   .UserParams 3 -1 roll 2 copy known {get exch pop}{pop pop} ifelse
  126. } bind def
  127. /.SetUserParam { % <prop-name> <key> <default-value> -> --
  128.   .GetUserParam .SetDmprtParam
  129. } bind def
  130.  
  131. %%%%%                     dviprt proparties                        %%%%%
  132.  
  133. mark
  134. .UserParams /printer 2 copy known {
  135.   get dup type /dicttype ne { mark /FileName 3 -1 roll .dicttomark } if
  136. }
  137. { pop pop % Default printer is `ESC/P 24 pins'.
  138.     mark
  139.     /Name          (ESC/P 24 pins)
  140.     /Transpose     true
  141.     /Reverse       false
  142.     /NonMoving     false
  143.     /Encoding      (Null)
  144.     /HDpi           180
  145.     /VDpi           180
  146.     /Pins          24
  147.     /MinimalUnit   1
  148.     /MaximalUnit   180
  149.     /Constant      1
  150.     /BitImageMode  (\007\0333\030\033?Z\047)
  151.     /NormalMode    (\004\015\014\0332)
  152.     /SendBitImage  (\002\033Z\002\001\200)
  153.     /SkipSpaces    (\002\033\\\002\001\200)
  154.     /LineFeed      (\002\015\012)
  155.     /FormFeed      (\002\015\014)
  156.     /AfterBitImage ()
  157.     /BitRowHeader  ()
  158.     .dicttomark
  159. } ifelse
  160. /DviprtParams exch .DmprtDevice putdeviceprops
  161.  
  162. getdeviceprops .dicttomark /.DmprtParams exch def
  163. .DmprtParams /DviprtParams get /.DviprtParams exch def
  164. .DmprtParams /DmprtParams get /.LocalParams exch def
  165.  
  166. % calcurate resolutions and define operators converting
  167. % from user-coordination to device-coordination(count by dots).
  168. /resolution [ .DviprtParams dup /HDpi get exch /VDpi get ]
  169.   .GetUserParam {} forall /.Ydpi exch def /.Xdpi exch def
  170. /.Xdot { dup type /arraytype eq { 0 get } { .Xdpi mul truncate cvi } ifelse
  171. } bind def
  172. /.Ydot { dup type /arraytype eq { 0 get } { .Ydpi mul truncate cvi } ifelse
  173. } bind def
  174.  
  175. %%%%%           Standard Ghostscript device propaties.             %%%%%
  176.  
  177. /HWSize  % default is A4.
  178.   /defaultsize [8.3 11.7] .GetUserParam
  179.   [ exch dup 0 get .Xdot exch 1 get .Ydot ] .SetDmprtParam
  180.  
  181. %%%%%                   dmprt device propaties.                    %%%%%
  182.  
  183. /MaxSize
  184.   /maxsize [0.0 0.0] .GetUserParam [ exch dup 0 get .Xdot exch 1 get .Ydot ]
  185.   .SetLocalParam
  186. /Margins /margin [0.0 0.0 0.0 0.0] .GetUserParam
  187.   [ exch dup 0 get .Xdot exch dup 1 get .Ydot
  188.     exch dup 2 get .Xdot exch     3 get .Ydot ] .SetLocalParam
  189. /Verbose QUIET {false}
  190.   {/verbose false .GetUserParam} ifelse .SetLocalParam
  191. /Debug /debug false .GetUserParam .SetLocalParam
  192.  
  193. %%%%%                   Page device propaties.                     %%%%%
  194. %%%%%         See PostScript Reference Manual 2nd edition.         %%%%%
  195.  
  196. /HWResolution [ .Xdpi .Ydpi ] .SetDmprtParam
  197. /Offsets
  198.   /offset [0.0 0.0] .GetUserParam [ exch dup 0 get .Xdot exch 1 get .Ydot ]
  199.   .SetLocalParam
  200.  
  201. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  202.  
  203. mark .DmprtParams {} forall .DmprtDevice putdeviceprops pop
  204.  
  205. end
  206. %%%%%%%%%%%%%%%%%%%%%%%%%%%%   End of file   %%%%%%%%%%%%%%%%%%%%%%%%%%%
  207.