home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / printer / post.zip / PostScript.doc < prev    next >
Text File  |  1990-03-04  |  18KB  |  534 lines

  1. Postscript interpreter - user documentation
  2. ===========================================
  3.  
  4. Post V1.0 Copyright Adrian Aylward 1989, 1990
  5.  
  6. Free use and non-commercial reproduction of the binaries of this prerelease
  7. is permitted, providing that the copyright notices are not removed.
  8. Distribution by disk libraries is permitted provided only a nominal copying
  9. fee is charged.
  10.  
  11. All other rights are reserved.  For queries and bug reports write to the
  12. author:
  13.  
  14.         Adrian Aylward,
  15.         20 Maidstone Road,
  16.         SWINDON,
  17.         Wiltshire.
  18.         UK.
  19.  
  20. No responsibilities accepted for bugs, but please let me know so I can fix
  21. them.
  22.  
  23. Introduction
  24. ============
  25.  
  26. "Post" is a software based PostScript interpreter, presently running on the
  27. Amiga.  The source code is written in C, and should be fairly portable to
  28. other machines.  It supports the full Adobe language, with only minor
  29. variations.
  30.  
  31. Prerequisites
  32. =============
  33.  
  34. Post uses the Arp library (V39+), primarily for its file requestor.  For
  35. interactive working you also need ConMan (V1.3+).  Both these programs are
  36. widely available; any good BBS or PD/shareware library should have them.
  37. (ConMan is shareware.)  You may well have them installed on your machine
  38. already.
  39.  
  40. If you prefer not to install ConMan as you standard console handler, you
  41. will need to access it via an alternative device name, which you must
  42. specify by the CONDEV option.
  43.  
  44. You will need at least a megabyte of memory, more for high density printer
  45. output.
  46.  
  47. Command line interface
  48. ======================
  49.  
  50. usage:
  51.     post [files...] [IFF file] [SCREEN] [PRINTER] [INTERACTIVE]
  52.          [SIZE xyd..s..p.bc.] [MEM fhlv..] [CLOSEWB]
  53.          [CONDEV con] [MESSAGEPORT name] [USERBITMAP] [NOBREAK]
  54.  
  55. If you forget, type "post ?" to display this.
  56.  
  57. The input files
  58. ---------------
  59.  
  60. The interpreter reads the input files in turn.  When running interactively
  61. the input files are treated as startup files, and are rerun whenever the
  62. interpreter is restarted.  So you would normally specify just the standard
  63. startup file "init.ps", or an alternative of you own.  When running
  64. non-interactively you should in addition specify all the files you want to
  65. interpret, up to 5 in total; when the last is finished the interpreter will
  66. exit.
  67.  
  68. Printer output
  69. --------------
  70.  
  71. This is the default if neither the IFF nor SCREEN options are used, when
  72. running non-interactively.  The output is sent to the printer device as a
  73. graphic dump.
  74.  
  75. The interpreter will obtain default values for the page size, density, and
  76. number of colors from the current preferences.  If you use the default sizes
  77. make sure you have set the page size: run preferences and on the graphic 2
  78. screen set the width and height limits -  either bounded or absolute or in
  79. pixels.  The output defaults to black and white or 3 colour, according to
  80. the preferences.
  81.  
  82. IFF file output
  83. ---------------
  84.  
  85. This option will send the output to an IFF file.  Each IFF file contains a
  86. single FORM ILBM.  So that multiple pages may be created in a single run of
  87. the interpreter, sequence numbers are automatically generated:
  88.  
  89.     IFF path/fred*.pic   will generate  path/fred1.pic, path/fred2.pic ...
  90. and IFF path/fred??.pic  will generate  path/fred01.pic, path/fred02.pic ...
  91.  
  92. The default page size etc. is the same as for screen output.
  93.  
  94. SCREEN output
  95. -------------
  96.  
  97. This option  will send the output to a window on the interactive screen.  It
  98. implies interactive working.
  99.  
  100. You can generate screen, printer and IFF output at the same time.  But since
  101. screen output has to use chip memory and printer output at high resolution
  102. needs a large page buffer (about a megabyte for an A4 page at 300 dpi.) you
  103. will probably run out of memory if you attempt the two simultaneously.
  104.  
  105. The default screen size is the same as the workbench screen, but in
  106. interlace mode.  The default density is 75 pixels per inch.  The default
  107. number of colours is 3.  The page size is rounded up to the maximum size
  108. of the window.
  109.  
  110. The INTERACTIVE option
  111. ----------------------
  112.  
  113. This option causes the interpreter to run interactively.  A screen is opened
  114. and on it appears a requestor window for the parameters.  If you click on
  115. OK two windows will be opened, one for console input and output, and the
  116. other to display the page buffer.  Use the menus.
  117.  
  118. The SIZE option
  119. ---------------
  120.  
  121. The SIZE option sets the page size and density etc..
  122.  
  123.     SIZE "x..y..s..[x]d...[y]d..p.bc.?"
  124.  
  125. The page sizes ("x..y..s..") are in pixels, as decimal numbers; "s" sets
  126. the size of the bands, for band rendering to the printer.  Densities
  127. ([x]d..[y]d..) are in pixels per inch; "xd" or "yd" set the x or y density,
  128. and "d" sets both.
  129.  
  130. The printer density can be set by "p"; its value should be in the range 
  131. 1 to 7.
  132.  
  133. The number of colours is: "b" for black and white (1 bit plane), "c" or "c3"
  134. for 3 colour rgb (3 bit planes), and "c4" for 4 colour cmyk (4 bit planes).
  135.  
  136. The MEM option
  137. --------------
  138.  
  139. The MEM option controls the amount of memory allocated for workspace.
  140.  
  141. The memory defaults are chosen to suit a large machine processing relatively
  142. complex pages.  For simple screen output much lower minimums are possible -
  143. if you don't have enough memory on your machine try the small values
  144. instead.
  145.  
  146.     Default   Small
  147.     -------   -----
  148.     v280000  (80000)     Virtual machine memory
  149.      f60000   (1000)     Font cache
  150.      l60000   (8000)     Line drawing and image workspace
  151.      h20000   (1000)     Halftone buffer
  152.  
  153.      (x + 32) * y / 8    Page buffer
  154.  
  155. The default values should run on a 1MB machine with output to a black and
  156. white screeen; for colour output it is necessary to reduce the page size
  157. and/or memory sizes.  On a 2MB machine it should be possible to generate a
  158. complex A4 page of printer output at 300 dpi.
  159.  
  160. The CLOSEWB option
  161. ------------------
  162.  
  163. If memory is tight, you can try using this option to close down WorkBench
  164. while Post is running.  This only works if there are no application
  165. windows open on the WorkBench screen.
  166.  
  167. The CONDEV option
  168. -----------------
  169.  
  170. If you do not have ConMan installed as the default console handler, you
  171. must use this option to specify its device name (without the ":").
  172.  
  173. The MESSAGEPORT option
  174. ----------------------
  175.  
  176. This option can be used to drive Post from another program, for example
  177. ARexx, or to simulate an AmigaDOS device, or to support a form of display
  178. PostScript.  It is NOT useful for casual use from the CLI; it is documented
  179. in the programmers file "postmsg.h".
  180.  
  181. The USERBITMAP option
  182. ---------------------
  183.  
  184. This option can be used in conjunction with MESSAGEPORT to specify that the
  185. bitmap planes will be supplied by the message handler task and not by Post.
  186. Otherwise, it is ignored.
  187.  
  188. The NOBREAK option
  189. ------------------
  190.  
  191. This option disables the CTRL/C break exception handler.  It is primarily
  192. intended for debugging purposes, but may also be useful in conjunction with
  193. MESSAGEPORT.
  194.  
  195. The WorkBench interface
  196. =======================
  197.  
  198. Just click on the icon.  It always runs interactively.  You can set up
  199. default arguments by setting the ToolTypes; add a string "ARGS=...."
  200. and it will be parsed just like the CLI startup.  For example
  201. "ARGS=init.ps screen" will define the standard startup file and make the
  202. screen the default output.
  203.  
  204. The Menus
  205. =========
  206.  
  207. Project
  208.     Restart              Takes you back to the parameters requestor, after
  209.                          which the interpreter is reinitialised.
  210.  
  211.     Quit                 Quit from the program
  212.  
  213. File
  214.     Load font            Loads a file from the PSFonts: directory by default
  215.  
  216.     Load file            Loads a file, without saving or restoring the VM
  217.  
  218.     Run file             Runs a file, saving VM before and restoring after
  219.  
  220.     Interactive          Interprets interactive input
  221.  
  222. Control
  223.     Pause every page     Toggles pause every showpage/copypage
  224.  
  225.     Continue after pause Does just that
  226.  
  227.     Interrupt            Sends a break; equivalent to CTRL/C
  228.  
  229. Before and after executing a file the operand stack is cleared.  This is
  230. to prevent invalidrestore errors, particularly if interpretation ended in
  231. error with values on the stack.  If you need to leave things on the stack
  232. you will have to run the files from a driver file, or from the interactive
  233. window.  At the end of the file, (after any restore), the page is erased.
  234.  
  235. If you use the automatic font loading, as defined in the standard startup
  236. file "init.ps", the font will be discarded when the VM is restored.  To
  237. avoid repeated reloading of common fonts it may be better to use the "Load
  238. font" menu item to preload the ones you want.  N.B. there is no check to
  239. stop you loading the same one twice; it will probably work but it will
  240. waste memory.
  241.  
  242. Compatability
  243. =============
  244.  
  245. The interpreter is based upon the language (version "23.0") as described by
  246. the book:
  247.  
  248.     "PostScript Language Reference Manual"
  249.     Adobe Systems Incorporated,
  250.     Addison-Wesley 1985, ISBN 0-201-10174-2
  251.  
  252. File handling
  253. -------------
  254.  
  255. The files %stdin, %stdout, %stderr are permanently open as far as the
  256. operating system is concerned.  Attempts to close them will invalidate the
  257. file object but not close them to the operating system.  If they are
  258. connected to a terminal they will be unbuffered, so output will be
  259. transmitted immediately, without waiting for a "flush".  The special files
  260. %statementedit and %lineedit are not supported.
  261.  
  262. Error handling
  263. --------------
  264.  
  265. A new error "invalidstop" has been added.
  266.  
  267. The execution stack
  268. -------------------
  269.  
  270. The exact contents of the execution stack are not defined by the language
  271. reference manual, and cannot therefore be guaranteed to be the same as other
  272. implementations.  Dumping the stack is likely to yield useful debugging
  273. information but is not recommended for normal programming.
  274.  
  275. Colour mapping
  276. --------------
  277.  
  278. The interpreter can run with one bit plane (for black and white printers),
  279. 3 bit planes (red, green, blue) or 4 bit planes (cyan, magenta, yellow,
  280. black).  For screen output 3 bit planes are apropiate.  For a colour
  281. printer the 3 or 4 colour model can be used.  The output is always in
  282. binary; gray scale is supported only via the halftone mechanism.
  283.  
  284. For low resolution colour printers the 3 colour model is probably best.
  285. The 4 color model is for high resolution colour printers that can generate
  286. high frequency halftone screens, where a fourth screen is used to improve
  287. the quality of the blacks and grays.
  288.  
  289. (N.B. the preferences printer drivers only handle 3 colour model, so if
  290. you want to use the 4 colour model you will probably need to generate an
  291. IFF file and write your own print dump program.  They will however
  292. automatically use black the ribbon/ink if the printer has one)
  293.  
  294. The transformations between the RGB and the HSB models are based on those in
  295. the book:
  296.  
  297.     "Procedural Elements for Computer Graphics"
  298.     David F. Rogers,
  299.     McGraw-Hill 1985, ISBN 0-E07-053534-5.
  300.  
  301. Band Rendering
  302. --------------
  303.  
  304. For a high resolution printer the page buffer can be quite large (a megabyte
  305. or so).  If you don't have enough memory to hold the entire page at once you
  306. can render each one in several bands.  Set the "SIZE s..." option to the
  307. largest band size you have space for.  (For matrix printers it will probably
  308. be best to make it a multiple of the number of printer pins times the number
  309. of vertically displaced passes).  Then run the postscript program generating
  310. each page once for each band, using the "setband" operator, which is
  311. described below, to set the base for each band.  Start at a base of zero
  312. and increment the base by the band size until you reach the page height.
  313. Each band is sent to the printer as a separate graphic dump; the last band
  314. generates a form feed to eject the page.  You can use the "currentband"
  315. operator to calculate the number of bands needed:
  316.  
  317.     currentband 1 sub { setband pageproc } for 0 setband
  318.  
  319. will execute "pageproc" once for each band (remaining) on the page.  The
  320. procedure should execute copypage (or showpage) exactly once per iteration.
  321.  
  322. N.B. this technique is only suitable for printer output.
  323.  
  324. Fonts
  325. -----
  326.  
  327. There are no fonts built in to the interpreter; they must all be downloaded.
  328. The findfont operator will execute the error invalidfont if the font you
  329. request is not present in the font dictionary.  You can redefine it, perhaps
  330. to search the Unix/Amiga filing system to automatically download fonts or to
  331. substitute a default font.
  332.  
  333. The font caching will work significantly better if all your fonts have
  334. UniqueID's.  Then repeated makes of the same font with the same matrix will
  335. be cached, and cached character bitmaps can be retained even if the font
  336. is removed by a restore operation.  N.B. if fonts are downloaded after a
  337. save they will be removed by the corresponding restore; in the interests of
  338. efficiency it may therefore be better to preload them.
  339.  
  340. Operators omitted or changed
  341. ----------------------------
  342.  
  343.     banddevice
  344.  
  345. Not apropiate for the Unix/Amiga environment.
  346.  
  347.     bytesavailable
  348.  
  349. Since we can't tell how many bytes are available we always return -1.
  350.  
  351.     copypage
  352.  
  353. For printer output this works like the standard.  For screen output it
  354. does not need to do anything, as the screen is not buffered.  Use Amiga/n
  355. and Amiga/m to view the screen and to return to the workbench screen.  If
  356. you want to add a pause to view the results, redefine the operator to add
  357. one.  For IFF file output it writes the page to the next file.
  358.  
  359.     echo
  360.  
  361. Not apropiate for the Unix/Amiga environment.
  362.  
  363.     executive
  364.  
  365. There is no executive, as the interpreter supports interactive usage
  366. directly.
  367.  
  368.     findfont
  369.  
  370. Looks in the FontDirectory.  If it can't find the supplied key, it execuctes
  371. the error invalidfont.
  372.  
  373.     flushfile
  374.  
  375. We don't check for errors when flushing an input file, to prevent recursion
  376. in the error handler.
  377.  
  378.     framedevice
  379.  
  380. Not apropiate for the Unix/Amiga environment.
  381.  
  382.     prompt
  383.  
  384. Not called by the interpreter.  See "prompts" instead.
  385.  
  386.     renderbands
  387.  
  388. Not apropiate for the Unix/Amiga environment.
  389.  
  390.     resetfile
  391.  
  392. Does nothing.
  393.  
  394.     showpage
  395.  
  396. See the notes for copypage above.
  397.  
  398.     start
  399.  
  400. Not used.  Write your own startup file if you want one.
  401.  
  402.     usertime
  403.  
  404. Returns the time elapsed since the interpreter started, with a resolution of
  405. one second.
  406.  
  407. Operators added
  408. ---------------
  409.  
  410.     currentband
  411.  
  412.         "currentband" base size height
  413.  
  414. Returns the base of the current band, size of each band, and total height
  415. of the page.
  416.  
  417.     setband
  418.  
  419.         base "setband"
  420.  
  421. Sets the base height of the band being rendered.  The value must be greater
  422. than or equal to zero and less than the total height of the page.
  423.  
  424.     invalidstop
  425.  
  426.         (error)
  427.  
  428. A "stop" has been executed for which there is no dynamically enclosing
  429. "stopped" context.
  430.  
  431.     prompts
  432.  
  433.         string string "prompts"
  434.  
  435. The first string is used as the prompt when the interpreter is scanning
  436. terminal input and executing it immediately; the second string is used when
  437. execution is defered while scanning the contents of a procedure "{ ... }".
  438. No prompt is given when a newline is encountered within a string.
  439.  
  440.     vmhwm
  441.  
  442.         "vmhwm" hwmused maximum
  443.  
  444. Returns two integers: the high water mark of the amount virtual memory used
  445. since the program was first started or the last "vmhwm", and the maximum
  446. available amount of memory.
  447.  
  448. Colour operators not in the red book
  449. ------------------------------------
  450.  
  451. The Adobe 4 colour operators are supported:
  452.  
  453.     colorimage
  454.     currentblackgeneration
  455.     currentcmykcolor
  456.     currentcolorscreen
  457.     currentcolortransfer
  458.     currentundercolorremoval
  459.     setblackgeneration
  460.     setcmykcolor
  461.     setcolorscreen
  462.     setcolortransfer
  463.     setundercolorremoval
  464.  
  465. Miscellaneous
  466. -------------
  467.  
  468. The system dictionary is left writeable so that standard preludes can add
  469. things to it - possibly removing write permission when they have finished.
  470.  
  471. Device space
  472. ------------
  473.  
  474. The largest device that the interpreter can handle is 31767 (sic.) by 32767
  475. pixels.  In practice you will probably run out of memory long before
  476. reaching this limit.
  477.  
  478. Known Bugs
  479. ==========
  480.  
  481. If you close down WorkBench the menus sometimes get truncated and slightly
  482. corrupted.  I suspect this is a Workbench/Intuition problem.
  483.  
  484. If you type CTRL/C to abort if the printer is not ready then strange things
  485. may happen on subsequent attempts to print.
  486.  
  487. N.B. if you run very low on memory, Intuition may behave strangely, and
  488. refuse to resize windows etc..  This is not a bug in Post.
  489.  
  490. Versions
  491. ========
  492.  
  493.     V0.0  14-Nov-89 (prerelease)
  494.  
  495. The original.
  496.  
  497.     V0.1  06-Dec-89 (prerelease)
  498.  
  499. Image routines added.
  500.  
  501. Range checks eased on gray levels and colours etc..
  502.  
  503. Area filling speeded up, matrix manipulation and colour mapping rewritten,
  504. numeric conditioning improved for path fill.
  505.  
  506. Bugs fixed: syntax error, == string escapes, error handling and quit when
  507. recursing, vm error handling, integer overflow in path fill, matrix save,
  508. interrupt after printing page, dictionary second save, name table restore,
  509. boolean type checking, multiple halftone screens memory allocation.
  510.  
  511.     V0.2  07-Jan-90 (prerelease)
  512.  
  513. Font and character routines added.  Null device added.  Band rendering of
  514. printer output added.
  515.  
  516. Matrix manipulation rewritten again.  Interpreter recursion rewritten.
  517. Allocate stacks dynamically.
  518.  
  519. Bugs fixed: missing access checks on strings, scan token negative chars,
  520. depth check in path flattening, pathbbox, strings or null objects as
  521. dictionary keys, shade after grestore(all), fill/image with clip region,
  522. clip unclosed subpath, dictstack/execstack.
  523.  
  524.     V1.0  12-Feb-90
  525.  
  526. Supports for big scrollable windows added.  Menu handler added with port
  527. name option.  Workbench startup added with parameters requestor window.
  528.  
  529. Hex string scan optimised.  Break now CTRL/C only, not CTRL/D.
  530.  
  531. Bugs fixed: aspect ratio in iff file, clipping pictures musch wider than the
  532. page.
  533.  
  534.