home *** CD-ROM | disk | FTP | other *** search
- Postscript interpreter - user documentation
- ===========================================
-
- Post V0.2 Copyright Adrian Aylward 1989, 1990
-
- Free use and non-commercial reproduction of the binaries of this prerelease
- is permitted, providing that the copyright notices are not removed.
- Distribution by disk libraries is permitted provided only a nominal copying
- fee is charged.
-
- All other rights are reserved. For queries and bug reports write to the
- author:
-
- Adrian Aylward,
- 20 Maidstone Road,
- SWINDON,
- Wiltsire.
- UK.
-
- No responsibilities accepted for bugs, but please let me know so I can fix
- them.
-
- Introduction
- ============
-
- "Post" is a software based PostScript interpreter, presently running on the
- Amiga. The source code is written in C, and should be fairly portable to
- other machines. It supports the full Adobe language, with only minor
- variations.
-
- Being a prerelease there will likely be bugs.
-
- Command line interface
- ======================
-
- usage:
- post [files...] [IFF file] [SCREEN] [SIZE xydxy..lhi?] [MEM fhlv..?]
-
- The input files
- ---------------
-
- The interpreter reads the input files in turn. If none are present, the
- standard input is read instead. (The standard input may also be explicity
- read as "%stdin".) If the input appears to be interactive, prompts will
- be displayed. When the end of the last file is reached, the program exits.
-
- Printer output
- --------------
-
- This is the default if neither the IFF nor SCREEN options are used. The
- oputput is sent to the printer device as a graphic dump.
-
- The interpreter will obtain default values for the page size, density, and
- number of colors from the current preferences. If you use the default sizes
- make sure you have set the page size: run preferences and on the graphic 2
- screen set the width and height limits - either bounded or absolute or in
- pixels. The output defaults to black and white or 3 colour, according to
- the preferences.
-
- IFF file output
- ---------------
-
- This option will send the output to an IFF file. Each IFF file comtains a
- single FORM ILBM. So that multiple pages may be created in a single run of
- the interpreter, sequence nubers are automatically generated:
-
- IFF path/fred*.pic will generate path/fred1.pic, path/fred2.pic ...
- and IFF path/fred??.pic will generate path/fred01.pic, path/fred02.pic ...
-
- The default page size etc. is the same as for screen output.
-
- SCREEN output
- -------------
-
- This option will send the output to a screen. (Use Amiga/N, Amiga/M to
- view it.) You can generate both screen and IFF output at the same time.
-
- The default screen size is the same as the workbench screen, but in
- interlace mode. The default density is 75 pixels per inch. The default
- number of colours is 3.
-
- The SIZE option
- ---------------
-
- The SIZE option sets the page size and density etc..
-
- SIZE "x..y..s..[x]d...[y]d..lhibc.?"
-
- The page sizes ("x..y..s..") are in pixels, as decimal numbers; "s" sets
- the size of the bands, for band rendering to the printer. Densities
- ([x]d..[y]d..) are in pixels per inch; "xd" or "yd" set the x or y density,
- and "d" sets both.
-
- The screen resolution is: "l" for low resolution no interlace, "h" for high
- resolution no interlace, and "i" for high resolution interlaced.
-
- The number of colours is: "b" for black and white (1 bit plane), "c" or "c3"
- for 3 colour rgb (3 bit planes), and "c4" for 4 colour cmyk (4 bit planes).
-
- To verify the sizes, type SIZE "?".
-
- The MEM option
- --------------
-
- The MEM option controls the amount of memory allocated for workspace.
-
- The memory defaults are chosen to suit a large machine processing relatively
- complex pages. For simple screen output much lower minimums are possible -
- if you don't have enough memory on your machine try the small values
- instead.
-
- Default Small
- ------- -----
- v280000 (40000) Virtual machine memory
- f60000 (1000) Font cache
- l60000 (8000) Line drawing and image workspace
- h20000 (1000) Halftone buffer
-
- (x + 32) * y / 8 Page buffer
-
- At the one extreme it should be possible to generate simple screen output
- using the small values on 512K machine, whereas the default values for a
- complex A4 page at 300 dpi. should fit on a machine with 2 megabytes. If
- you include "?" the interpreter will tell you the sizes it is using.
-
- Compatability
- =============
-
- The interpreter is based upon the language (version "23.0") as described by
- the book:
-
- "PostScript Language Reference Manual"
- Adobe Systems Incorporated,
- Addison-Wesley 1985, ISBN 0-201-10174-2
-
- File handling
- -------------
-
- The files %stdin, %stdout, %stderr are permanently open as far as the
- operating system is concerned. Attempts to close them will invalidate the
- file object but not close them to the operating system. If they are
- connected to a terminal they will be unbuffered, so output will be
- transmitted immediately, without waiting for a "flush". The special files
- %statementedit and %lineedit are not supported.
-
- Error handling
- --------------
-
- A new error "invalidstop" has been added.
-
- The execution stack
- -------------------
-
- The exact contents of the execution stack are not defined by the language
- reference manual, and cannot therefore be guaranteed to be the same as other
- implementations. Dumping the stack is likely to yield useful debugging
- information but is not recommended for normal programming.
-
- Colour mapping
- --------------
-
- The interpreter can run with one bit plane (for black and white printers),
- 3 bit planes (red, green, blue) or 4 bit planes (cyan, magenta, yellow,
- black). For screen output 3 bit planes are appropiate. For a colour
- printer the 3 or 4 colour model can be used. The output is always in
- binary; gray scale is supported only via the halftone mechanism.
-
- For low resolution colour printers the 3 colour model is probably best.
- The 4 color model is for high resolution colour printers that can generate
- high frequency halftone screens, where a fourth screen is used to improve
- the quality of the blacks and grays.
-
- (N.B. the preferences printer drivers only handle 3 colour model, so if
- you want to use the 4 colour model you will probably need to generate an
- IFF file and write your own print dump program. They will however
- automatically use black the ribbon/ink if the printer has one)
-
- The transformations between the RGB and the HSB models are based on those in
- the book:
-
- "Procedural Elements for Computer Graphics"
- David F. Rogers,
- McGraw-Hill 1985, ISBN 0-E07-053534-5.
-
- Band Rendwring
- --------------
-
- For a high resolution printer the page buffer can be quite large (a megabyte
- or so). If you don't have enough memory to hold the entire page at once you
- can render each one in several bands. Set the "SIZE s..." option to the
- largest band size you have space for. (For matrix printers it will probably
- be best to make it a multiple of the number of printer pins times the number
- of vertically displaced passes). Then run the postscript program generating
- each page once for each band, using the "setband" operator, which is
- described below, to set the base for each band. Start at a base of zero
- and increment the base by the band size until you reach the page height.
- Each band is sent to the printer as a separate graphic dump; the last band
- generates a form feed to eject the page. You can use the "currentband"
- operator to calculate the number of bands needed:
-
- currentband 1 sub { setband pageproc } for 0 setband
-
- will execute "pageproc" once for each band (remaining) on the page. The
- procedure should execute copypage (or showpage) exactly once per iteration.
-
- N.B. this technique is only suitable for printer output.
-
- Fonts
- -----
-
- There are no fonts built in to the interpreter; they must all be downloaded.
- The findfont operator will execute the error invalidfont if the font you
- request is not present in the font dictionary. You can redefine it, perhaps
- to search the Unix/Amiga filing system to automatically download fonts or to
- substitute a default font.
-
- The font caching will work significantly better if all your fonts have
- UniqueID's. Then repeated makes of the same font with the same matrix will
- be cached, and cached character bitmaps can be retained even if the font
- is removed by a restore operation. N.B. if fonts are downloaded after a
- save they will be removed by the corresponding restore; in the interests of
- efficiency it may therefore be better to preload them.
-
- Operators omitted or changed
- ----------------------------
-
- banddevice
-
- Not appropiate for the Unix/Amiga environment.
-
- bytesavailable
-
- Since we can't tell how many bytes are available we always return -1.
-
- copypage
-
- For printer output this works like the standard. For screen output it
- does not need to do anything, as the screen is not buffered. Use Amiga/n
- and Amiga/m to view the screen and to return to the workbench screen. If
- you want to add a pause to view the results, redefine the operator to add
- one. For IFF file output it writes the page to the next file.
-
- echo
-
- Not appropiate for the Unix/Amiga environment.
-
- executive
-
- There is no executive, as the interpreter supports interactive usage
- directly.
-
- findfont
-
- Looks in the FontDirectory. If it can't find the supplied key, it exeuctes
- the error invalidfont.
-
- flushfile
-
- We don't check for errors when flushing an input file, to prevent recursion
- in the error handler.
-
- framedevice
-
- Not appropiate for the Unix/Amiga environment.
-
- prompt
-
- Not called by the interpreter. See "prompts" instead.
-
- renderbands
-
- Not appropiate for the Unix/Amiga environment.
-
- resetfile
-
- Does nothing.
-
- showpage
-
- See the notes for copypage above.
-
- start
-
- Not used. Write your own startup file if you want one.
-
- usertime
-
- Returns the time elapsed since the interpreter started, with a resolution of
- one second.
-
- Operators added
- ---------------
-
- currentband
-
- "currentband" base size height
-
- Returns the base of the current band, size of each band, and total height
- of the page.
-
- setband
-
- base "setband"
-
- Sets the base height of the band being rendered. The value must be greater
- than or equal to zero and less than the total height of the page.
-
- invalidstop
-
- (error)
-
- A "stop" has been executed for which there is no dynamically enclosing
- "stopped" context.
-
- prompts
-
- string string "prompts"
-
- The first string is used as the prompt when the interpreter is scanning
- terminal input and executing it immediately; the second string is used when
- execution is defered while scanning the contents of a procedure "{ ... }".
- No prompt is given when a newline is encountered within a string.
-
- vmhwm
-
- "vmhwm" hwmused maximum
-
- Returns two integers: the high water mark of the amount virtual memory used
- since the program was first started or the last "vmhwm", and the maximum
- available amount of memory.
-
- Colour operators not in the red book
- ------------------------------------
-
- The Adobe 4 colour operators are supported:
-
- colorimage
- currentblackgeneration
- currentcmykcolor
- currentcolorscreen
- currentcolortransfer
- currentundercolorremoval
- setblackgeneration
- setcmykcolor
- setcolorscreen
- setcolortransfer
- setundercolorremoval
-
- Miscellaneous
- -------------
-
- The system dictionary is left writeable so that standard preludes can add
- things to it - possibly removing write permission when they have finished.
-
- Device space
- ------------
-
- The largest device that the interpreter can handle is 31767 (sic.) by 32767
- pixels. In practice you will probably run out of memory long before
- reaching this limit.
-
- Versions
- ========
-
- V0.0 14-Nov-89 (prerelease)
-
- The original.
-
- V0.1 06-Dec-89 (prerelease)
-
- Image routines added.
-
- Range checks eased on gray levels and colours etc..
-
- Area filling speeded up, matrix manipulation and colour mapping rewritten,
- numeric conditioning improved for path fill.
-
- Bugs fixed: syntax error, == string escapes, error handling and quit when
- recursing, vm error handling, integer overflow in path fill, matrix save,
- interrupt after printing page, dictionary second save, name table restore,
- boolean type checking, multiple halftone screens memory allocation.
-
- V0.2 07-Jan-90 (prerelease)
-
- Font and character routines added. Null device added. Band rendering of
- printer output added.
-
- Matrix manipulation rewritten again. Interpreter recursion rewritten.
- Allocate stacks dynamically.
-
- Bugs fixed: missing access checks on strings, scan token negative chars,
- depth check in path flattening, pathbbox, strings or null objects as
- dictionary keys, shade after grestore(all), fill/image with clip region,
- clip unclosed subpath, dictstack/execstack.
-