Postscript is a programming language (in reverse polish notation, see [RPN in Tcl]) that is used mostly for representing printable documents. More decent printers usually understand (interpret) Postscript right away. Popular tools to visualize Postscript files are ''ghostscript/ghostview'' [http://www.cs.wisc.edu/~ghost/]. - [RS]: '''Recent versions of the [Img] library allow Tcl to render Postscript too.''' Here's a tiny renderer that can do big pages (notice that Postscript is nowhere mentioned - ''[image] create'' just can do it, thanks to Img): ---- package require Img canvas .c -xscrollc ".x set" -yscrollc ".y set" scrollbar .x -ori hori -command ".c xview" scrollbar .y -ori vert -command ".c yview" grid .c .y -sticky news grid .x -sticky news grid rowconfig . 0 -weight 1 grid columnconfig . 0 -weight 1 set im [image create photo -file [lindex $argv 0]] .c create image 0 0 -image $im -anchor nw .c configure -scrollregion [.c bbox all] ---- Also, [Tk]'s [canvas] widget can dump most of its contents in Postscript - obviously, with the ''postscript'' subcommand. The Postscript Language Reference Manual and some related specifications can be found at [http://partners.adobe.com/asn/developer/technotes/postscript.html]. Syntax in brief: Words are separated by whitespace, but the ten special characters %/(){}[[]]<> also end the previous word (with some exceptions). % starts a comment, that continues to the end of the line. / before a word makes that word literal (prevents that it is executed). Parentheses delimit strings; \ is escape character in strings. Braces delimit procedures (executable arrays); they work sort of like in Tcl. Brackets construct normal arrays, which are similar to lists in Tcl, except that they have fixed length :-(. The PS code a [b /c /d e] f is sort of equivalent to Tcl $a [list $b c d $e] $f or (if f is more of a command than a variable) f $a [list $b c d $e] A typical Postscript file starts with a %! comment, and it usually contains a couple of %% comments that contain markup for programs that manipulate Postscript files. %! %%Creator: Gif2PS /#copies 1 def The last line is an assignment: "assign to the variable #copies the value 1", or ''set #copies 1'' as we would say in Tcl. See also [Manipulating Postscript]. ---- Postscript also has a few other interesting datatypes (notably dictionaries, which are sort-of like arrays in Tcl) and it is possible to write postscript code that manipulates functions written in postscript. In fact, functions are really executable arrays (arrays of PS primitives) that are bound to a name in a dictionary that's on the dictionary stack (which effectively forms a search path for command name resolution.) Note that you don't have ''any'' local variables. But you can insert a private dictionary into an executable array in a way that functions virtually the same. Which is either cute or disgusting, depending on your point-of-view. :^) ---- '''PostScript Fonts''' The PostScript language supports three main types of fonts, being ''stroked'' fonts, ''bitmap'' fonts and ''computed'' fonts (and I think that's the order of the type codes too.) It also supports ''composite'' fonts, which are built up out of other fonts. Stroked fonts are scalable fonts with each character described by a path (general shape) which is then filled to display the character. Bitmapped fonts are not really scalable (you get horrible rendering artifacts) but are easy to create from all sorts of sources. Computed fonts are rarely used, since the form of most characters are not really describable mathematically. All fonts also come with various extra pieces of information like [kerning] rules, etc. Generally, you'll want to stick to stroked (Type 1) fonts for printing purposes where possible as they look good at all resolutions and sizes. When it comes to rendering PS fonts on screen, they often don't do quite as well as [TrueType] fonts as Type 1 fonts don't come as heavily annotated with hints for how to handle low-resolution display. This is only really a problem if you don't use [antialias]ing though. [DKF], 12-Jun-2003 ---- [Category Language]