Ghostscript’s capabilities in relation to PostScript
The Ghostscript interpreter, except as noted below, is intended to execute properly any source program written in the (LanguageLevel 3) PostScript language as defined in the PostScript Language Reference, Third Edition (ISBN 0-201-37922-8) published by Addison-Wesley in mid-1999. However, the interpreter is configurable in ways that can restrict it to various subsets of this language. Specifically, the base interpreter accepts the Level 1 subset of the PostScript language, as defined in the first edition of the PostScript Language Reference Manual (ISBN 0-201-10174-2) Addison-Wesley 1985, plus the file system, version 25.0 language, and miscellaneous additions listed in sections A.1.6, A.1.7, and A.1.8 of the Second Edition respectively, including allowing a string operand for the “status” operator. The base interpreter may be configured (see the documentation on building Ghostscript for how to configure it) by adding any combination of the following:
The ability to process PostScript Type 1 fonts. This facility is normally included in the interpreter.
The CMYK color extensions listed in section A.1.4 of the Second Edition (including colorimage). These facilities are available only if the color, dps, or level2 feature was selected when Ghostscript was built.
The Display PostScript extensions listed in section A.1.3 of the Second Edition, but excluding the operators listed in section A.1.2. These facilities are available only if the dps feature or the level2 feature was selected when Ghostscript was built.
The composite font extensions listed in section A.1.5 of the Second Edition, and the ability to handle Type 0 fonts. These facilities are available only if the compfont feature or the level2 feature was selected when Ghostscript was built.
The ability to load TrueType fonts and to handle PostScript Type 42 (encapsulated TrueType) fonts. These facilities are available only if the ttfont feature was selected when Ghostscript was built.
The PostScript Level 2 “filter” facilities except the DCTEncode and DCTDecode filters. These facilities are available only if the filter, dps, or level2 feature was selected when Ghostscript was built.
The PostScript Level 2 DCTEncode and DCTDecode filters. These facilities are available only if the dct or level2 feature was selected when Ghostscript was built.
All the other PostScript Level 2 operators and facilities listed in section A.1.1 of the Second Edition and not listed in any of the other A.1.n sections. These facilities are available only if the level2 feature was selected when Ghostscript was built.
All PostScript LanguageLevel 3 operators and facilities listed in the Third Edition, except as noted below. These facilities are available only if the psl3 feature was selected when Ghostscript was built.
The ability to recognize DOS EPSF files and process only the PostScript part, ignoring bitmap previews or other information. This facility is available only if the epsf feature was selected when Ghostscript was built.
Ghostscript currently does not implement the following PostScript LanguageLevel 3 facilities:
Native Separation and DeviceN color spaces — the alternate space is always used.
Settable ProcessColorModel for page devices, except for a very few special devices.
IODevices other than %stdin, %stdout, %stderr, %lineedit, %statementedit, %os%, and (if configured) %pipe%.
Ghostscript can also interpret files in the Portable Document Format (PDF) 1.3 format defined in the Portable Document Format Reference Manual Version 1.3 of March 11, 1999, distributed by Adobe Systems Incorporated, except as noted below. This facility is available only if the pdf feature was selected when Ghostscript was built.
Ghostscript currently does not implement the following PDF 1.3 facilities:
Native Separation and DeviceN color spaces, as noted above for PostScript.
Native ICCBased color spaces — these too always use the alternate space.
Ghostscript also includes a number of additional operators defined below that are not in the PostScript language defined by Adobe.
The implementation limits show here correspond to those in Tables B.1 and B.2 of the Second and Third Editions, which describe the quantities fully. Where Ghostscript’s limits are different from those of Adobe’s implementations (as shown in the Third Edition), Adobe’s limits are also shown.
* The limit on the length of a file name is 128 characters if the name starts with a %. % IODevice designation, or 124 characters if it does not.
Typical memory limits in LanguageLevel 1
for1-, 2-, 4-, or 8-bit samples
Other differences in VM consumption
Packed array elements occupy either 2 bytes or 8 bytes. The average element size is probably about 5 bytes. Names occupy 12 bytes plus the space for the string.
Additional operators in Ghostscript
Graphics and text operators
Ghostscript provides a set of operators for implementing the transparency and compositing facilities of PDF 1.4. These are defined only if the transpar option was selected when Ghostscript was built. We do not attempt to explain the underlying graphics model here: for details, see Adobe Technical Note #5407, “Transparency in PDF”. Note, however, that Ghostscript’s model generalizes that of PDF 1.4 in that Ghostscript maintains separate alpha and mask values for opacity and shape, rather than a single value with a Boolean that says whether it represents opacity or shape. EVERYTHING IN THIS SECTION IS SUBJECT TO CHANGE.
Graphics state operators
Rendering stack operators
The interpreter state is extended to include a (per-context) rendering stack for handling transparency groups and masks (generically, “layers”). Groups accumulate a full value for each pixel (paint plus transparency); masks accumulate only a coverage value. Layers must be properly nested, i.e., the ‘end’ or ‘discard’ operator must match the corresponding ‘begin’ operator.
Beginning and ending layers must nest properly with respect to save and restore: save and restore do not save and restore the layer stack. Currently, layers are not required to nest with respect to gsave and grestore, except that the device that is current in the graphics state when ending a layer must be the same as the device that was current when beginning the layer. THIS AREA IS SUBJECT TO CHANGE. <paramdict> <llx> <lly> <urx> <ury> .begintransparencygroup - Begins a new transparency group. The ll/ur coordinates are the bounding box of the group in the current user coordinate system. paramdict has the following keys: /Isolated (optional) Boolean; default value = false. /Knockout (optional) Boolean; default value = false. - .discardtransparencygroup - Ends and discards the current transparency group. - .endtransparencygroup - Ends the current transparency group, compositing the group being ended onto the group that now becomes current. <paramdict> <llx> <lly> <urx> <ury> .begintransparencymask - Begins a new transparency mask. The ll/ur coordinates are the bounding box of the mask in the current user coordinate system. paramdict has the following keys: /Subtype (required) Name, either /Alpha or /Luminosity. /Background (optional) Array of number. /TransferFunction (optional) Function object (produced by applying .buildfunction to a Function dictionary). - .discardtransparencymask - Ends and discards the current transparency mask. <masknum> .endtransparencymask - Ends the current transparency mask, installing it as the current opacity (masknum = 0) or shape (masknum = 1) mask in the graphics state. <masknum> .inittransparencymask - Resets the current opacity (masknum = 0) or shape (masknum = 1) mask to an infinite mask with alpha = 1 everywhere.
The transparency extension defines a new ImageType 103, similar to ImageType 3 with the following differences:
The required MaskDict is replaced by two optional dictionaries, OpacityMaskDict and ShapeMaskDict. If present, these dictionaries must have a BitsPerComponent entry, whose value may be greater than 1. Note that in contrast to ImageType 3, where any non-zero chunky mask value is equivalent to 1, ImageType 103 simply takes the low-order bits of chunky mask values.
A Matte entry may be present in one or both mask dictionaries, indicating premultiplication of the data values. If both MaskDicts have a Matte entry and the values of the two Matte entries are different, a rangecheck error occurs.
InterleaveType appears in the MaskDicts, not the DataDict, because each mask has its own InterleaveType. InterleaveType 2 (interlaced scan lines) is not supported.
Other graphics state operators
Ghostscript supports an experimental extension of the PostScript imaging model to include RasterOp and some related facilities. This extension is available only if the rasterop option was selected when building Ghostscript.
With the RasterOp extension, imaging operations compute a function D = f(D,S,T) in RGB space, where f is an arbitrary 3-input Boolean function, D is the destination (frame buffer or print buffer), S is the source (described below), and T is the texture (the current PostScript color, which may be a pattern). The source and texture depend on the PostScript imaging operation:
For fill and stroke, the source is solid black, covering the region to be painted; the texture is the current PostScript color.
For show and imagemask, the source is solid black, covering the pixels to be painted; the texture is the current PostScript color.
For image and colorimage, the source is the image data; the texture depends on an optional Boolean parameter, CombineWithColor, in the image dictionary. If CombineWithColor is false (the default), the texture is solid black. If CombineWithColor is true, the texture is the current color. For the non-dictionary form of the image operator, CombineWithColor is considered to be false.
The rasterop option adds the following operators: <int8> .setrasterop - Sets the RasterOp function in the graphics state. The default function is 252, Source | Texture. - .currentrasterop <int8> Returns the current RasterOp function. <bool> .setsourcetransparent - Sets source transparency in the graphics state. When source transparency is true, white source pixels prevent storing into the destination, regardless of what the RasterOp function returns. The default source transparency is false. - .currentsourcetransparent <bool> - Returns the current source transparency. <bool> .settexturetransparent - Sets texture transparency in the graphics state. When texture transparency is true, white texture pixels prevent storing into the destination, regardless of what the RasterOp function returns. The default texture transparency is false. - .currenttexturetransparent <bool> - Returns the current texture transparency.
For more information on RasterOp and transparency, please consult chapter 5 of the “PCL 5 Color Technical Reference Manual”, Hewlett-Packard Manual Part No. 5961-0635.
This creates a path whose pathbbox is the bbox of the string.
If <bool> is false, the equivalent of: p1x p1y moveto
If the CTM is well-behaved (consists only of reflection, scaling, and rotation by multiples of 90 degrees), this too creates a (simpler) path whose pathbbox is the bbox of the string. <font> <charname|charcode> <charname> <charstring> .type1execchar - Does all the work for rendering a Type 1 outline. This operator, like setcharwidth and setcachedevice, is valid only in the context of a show operator — that is, it must only be called from within a BuildChar or BuildGlyph procedure. <font> <charcode> %Type1BuildChar - This is not a new operator: rather, it is a name known specially to the interpreter. Whenever the interpreter needs to render a character (during a . show, stringwidth, or charpath), it looks up the name BuildChar in the font dictionary to find a procedure to run. If it does not find this name, and if the FontType is 1, the interpreter instead uses the value (looked up on the dictionary stack in the usual way) of the name %Type1BuildChar.
The standard definition of %Type1BuildChar is in the initialization file gs_type1.ps. Users should not need to redefine %Type1BuildChar, except perhaps for tracing or debugging. <font> <charname> %Type1BuildGlyph - Provides the Type 1 implementation of BuildGlyph.
String and name operators
It is intended that in some future version of Ghostscript, files opened with .tempfile will be closed and deleted automatically when Ghostscript exits; however, this is not currently the case (version 7.01). <file> <integer> .unread - Pushes back the last-read character onto the front of the file. If the file is open only for writing, or if the integer argument is not the same as the last character read from the file, causes an ioerror error. May also cause an ioerror if the last operation on the file was not a reading operation. This operator is now deprecated: use .peekstring in new code.
Ghostscript also supports the following IODevice in addition to a subset of those defined in the Adobe documentation: %pipe%command, which opens a pipe on the given command. This is supported only on operating systems that provide popen (primarily Unix systems, and not all of those).
Virtual memory operators
except that it doesn’t actually create the array. <string> getenv <string> true<string> getenv false Looks up a name in the shell environment. If the name is found, returns the corresponding value and true; if the name is not found, returns false. <name> <array> .makeoperator <operator> Constructs and returns a new operator that is actually the given procedure in disguise. The name is only used for printing. The operator has the executable attribute.
Operators defined in this way do one other thing besides running the procedure: if an error occurs during the execution of the procedure, and there has been no net reduction in operand or dictionary stack depth, the operand or dictionary stack pointer respectively is reset to its position at the beginning of the procedure. <string> <boolean> .setdebug - If the Ghostscript interpreter was built with the DEBUG flag set, sets or resets any subset of the debugging flags normally controlled by -Z in the command line. Has no effect otherwise. - .oserrno <errno> Returns the error code for the most recent operating system error. - .oserrorstring <string> Returns the error string for the most recent operating system error.
Alternatively, palette can be 16, 24, 32, or null (equivalent to 24). These are interpreted as:
Note that one can also make an image device (with the same palette as an existing image device) by copying a device using the copydevice operator. <matrix> <width> <height> <palette> <word?> makewordimagedevice <device> Makes an image device as described above. word? is a Boolean value indicating whether the data should be stored in a word-oriented format internally. No ordinary PostScript programs should use this operator. <device> <index> <string> copyscanlines <substring> Copies one or more scan lines from an image device into a string, starting at a given scan line in the image. The data is in the same format as for the image operator. It is an error if the device is not an image device or if the string is too small to hold at least one complete scan line. Always copies an integral number of scan lines. <device> setdevice - Sets the current device to the specified device. Also resets the transformation and clipping path to the initial values for the device. Signals an invalidaccess error if the device is a prototype. - currentdevice <device> Gets the current device from the graphics state. <device> getdeviceprops <mark> <name1> <value1> . <namen> <valuen> Gets the properties of a device. See the section on device parameters below for details. <mark> <name1> <value1> . <namen> <valuen> <device> putdeviceprops <device> Sets properties of a device. May cause undefined, typecheck, rangecheck, or limitcheck errors. - flushpage - On displays, flushes any buffered output, so that it is guaranteed to show up on the screen; on printers, has no effect.
In its usual configuration, Ghostscript supports all the standard PostScript LanguageLevel 3 filters, both encoding and decoding, except that it does not currently support:
the EarlyChange key in the LZWEncode filter.
Ghostscript also supports additional keys in the optional dictionary operands for some filters. For the LZWDecode filter: InitialCodeLength <integer> (default 8) An integer between 2 and 11 specifying the initial number of data bits per code. Note that the actual initial code length is 1 greater than this, to allow for the reset and end-of-data code values. FirstBitLowOrder <boolean> (default false) If true, codes appear with their low-order bit first. BlockData <boolean> (default false) If true, the data is broken into blocks in the manner specified for the GIF file format.
For the CCITTFaxEncode and CCITTFaxDecode filters: DecodedByteAlign <integer> (default 1) An integer N with the value 1, 2, 4, 8, or 16, specifying that decoded data scan lines are always a multiple of N bytes. The encoding filter skips data in each scan line from Columns to the next multiple of N bytes; the decoding filter pads each scan line to a multiple of N bytes.
In addition to the standard PostScript LanguageLevel 3 filters, Ghostscript supports the following non-standard filters. Many of these filters are used internally to implement standard filters or facilities; they are almost certain to remain, in their present form or a backward-compatible one, in future Ghostscript releases. <target> /BCPEncode filter <file><source> /BCPDecode filter <file> Create filters that implement the Adobe Binary Communications Protocol. See Adobe documentation for details. <target> <seed_integer> /eexecEncode filter <file> Creates a filter for encrypting data into the encrypted format described in the Adobe Type 1 Font Format documentation. The seed_integer must be 55665 for the eexec section of a font, or 4330 for a CharString. Note that for the eexec section of a font, this filter produces binary output and does not include the initial 4 (or lenIV) garbage bytes. <source> <seed_integer> /eexecDecode filter <file><source> <dict> /eexecDecode filter <file> Creates a filter for decrypting data encrypted as described in the Adobe Type 1 Font Format documentation. The seed_integer must be 55665 or 4330 as described just above. Recognized dictionary keys are: seed <16-bit integer> (required)
lenIV <non-negative integer> (default=4) <target> /MD5Encode filter <file> Creates a filter that produces the 16-byte MD5 digest of the input. Note that no output is produced until the filter is closed. <source> <hex_boolean> /PFBDecode filter <file> Creates a filter that decodes data in .PFB format, the usual semi-binary representation for Type 1 font files on IBM PC and compatible systems. If hex_boolean is true, binary packets are converted to hex; if false, binary packets are not converted. <target> <dict> /PixelDifferenceEncode filter <file><source> <dict> /PixelDifferenceDecode filter <file> Implements the Predictor=2 pixel-differencing option of the LZW filters. Recognized keys are: Colors <integer> (1 to 4, default=1)
BitsPerComponent <integer> (1, 2, 4, or 8, default=8)
The Predictor is the PNG algorithm number + 10 for the Encoding filter; the Decoding filter ignores Predictor. 15 means the encoder attempts to optimize the choice of algorithm. For more details see the PNG specification http://www.w3.org/TR/WD-png-960128.html <target> /TBCPEncode filter <file><source> /TBCPDecode filter <file> Create filters that implement the Adobe Tagged Binary Communications Protocol. See Adobe documentation for details. <target> /zlibEncode filter <file><source> /zlibDecode filter <file> Creates filters that use the data compression method variously known as ‘zlib’ (the name of a popular library that implements it), ‘Deflate’ (as in RFC 1951, which is a detailed specification for the method), ‘gzip’ (the name of a popular compression application that uses it), or ‘Flate’ (Adobe’s name). Note that the PostScript Flate filters are actually a combination of this filter with an optional predictor filter.
Some versions of Ghostscript may also support other non-standard filters for experimental purposes. The current version includes the following such filters, which are not documented further. No code should assume that these filters will exist in compatible form, or at all, in future versions. <target/source> <string> ByteTranslateEncode/Decode filter <file>string must be a string of exactly 256 bytes. Creates a filter that converts each input byte b to string[b]. Note that the Encode and Decode filters operate identically: the client must provide a string for the Decode filter that is the inverse mapping of the string for the Encode filter. <target/source> <dict> BoundedHuffmanEncode/Decode filter <file> These filters encode and decode data using Huffman codes. Since these filters aren’t used anywhere, we don’t document them further, except to note the recognized dictionary keys, which must be set identically for encoding and decoding: FirstBitLowOrder <bool> (default=false)
Tables <int_array><target/source> <dict> BWBlockSortEncode/Decode filter <file> This filter implements the Burroughs-Wheeler block sorting compression method, which we’ve heard is also used in the popular bzip2 compression application. See http://sources.redhat.com/bzip2/ for more information. The only recognized dictionary key is: BlockSize <integer> (default=16384) <target/source> MoveToFrontEncode/Decode filter <file> The Encode filter starts by initializing an internal 256-byte array a to the values 0 .. 255. This array will always hold a permutation of these values. Then for each input byte b, the filter outputs the index i such that a[i] = b, and moves that element to the front (element 0) of a, moving elements 0 .. i-1 to positions 1 .. i. The Decode filter inverts this process.
In addition, the following are defined per Adobe’s documentation for the setpagedevice operator: Duplex (if supported)
NumCopies (for printers only)
ProcessColorModel (usually read-only)
Some devices may only allow certain values for HWResolution and PageSize. The null device ignores attempts to set PageSize; its size is always [0 0].
For printers these are also defined: BufferSpace <integer> Buffer space for band lists, if the bitmap is too big to fit in memory. MaxBitmap <integer> Maximum space for a full bitmap in memory. OutputFile <string> An empty string means “send to printer directly”, otherwise specifies the file name for output; %d is replaced by the page number; on Unix systems %pipe%command writes to a pipe. (|command also writes to a pipe, but is now deprecated.) OpenOutputFile <boolean> If true, open the device’s output file when the device is opened, rather than waiting until the first page is ready to print. PageCount <integer> (read-only) Counts the number of pages printed on the device.
The following parameters are for use only by very specialized applications that separate band construction from band rasterization. Improper use may cause unpredictable errors. In particular, if you only want to allocate more memory for banding, to increase band size and improve performance, use the BufferSpace parameter, not BandBufferSpace. BandHeight <integer> The height of bands when banding. 0 means use the largest band height that will fit within the BandBufferSpace (or BufferSpace, if BandBufferSpace is not specified). BandWidth <integer> The width of bands in the rasterizing pass, in pixels. 0 means use the actual page width. BandBufferSpace <integer> The size of the band buffer in the rasterizing pass, in bytes. 0 means use the same buffer size as for the interpretation pass.
In addition, Ghostscript supports the following parameter for setpagedevice and currentpagedevice that is not a device parameter per se: ViewerPreProcess <procedure> Specifies a procedure to be applied to the page device dictionary before any other processing is done. The procedure may not alter the dictionary, but it may return a modified copy. This “hook” is provided for use by viewing programs such as GSview.
The main purpose here is not to teach each detail of this software but to give sufficient material for the persons who find PostScript an interesting and enjoyable programming language for document preparation. Although we do not intend to write a technical paper or a textbook or a bible on this topic we are going to try to present necessary and sufficient information for PostScript.
The main ideas behind PostScript were created twenty two years ago by John Gaffney at the Evans & Sutherland Computer Corporation. It was known as the “Design System” at the beginning but later it was developed under the name PostScript by Adobe Systems Incorporated as a platform and device independent tool for page designing. Adobe Systems Incorporated was formed by Chuck Geschke and John Warnock in 1982. C. Geschke and J. Warnock undertook a new design and implementation of the language, to which Doug Brotz, Billi Paxton, and Ed Taft made major contributions. Nowadays it is one of the major document preparation tools although it is not directly used by most end users. Its capabilities are at quite high levels however many lazy users who do not want to get into the details of this powerful language prefer to use the other end-user-oriented tools which are mainly based on the “What You See Is What You Get” philosophy. To tell the truth, many WYSIWYG tools use PostScript file formats for maintaining the documentation products or for using as an interface for other jobs like printing. In these senses, it still survives as our old friend which serves as a powerful assistance to many computer jobs related to drawing, coloring, image processing, color separation, simulation and animation even if it may not explicitly show up itself in the procedures. On the other hand, if you desire to learn its structure for programming you will find it not so difficult.
The PostScript commands are executed through certain interpreters. Amongst these, a well-known software is freely available on the public domain of Internet. This is named “ghostscript” by Aladdin Enterprise. There is also a useful graphical interface, “ghostview”, released by the same organization. GNU project has also its own versions for ghostscript. These are available in every Linux platform and all main Linux distributions contain them in standard installations. Here we deal with ghostscript and its certain specific structures and properties although the sample programs can be executed through other interpreters. Assume that we activate the X Window server and open an xterm window. If we want to use ghostscript then each command or command groups will be given at the command prompt which will be appeared after issuing the command
Initializing. done. Ghostscript 2.6.2 (4/19/95) Copyright (C) 1990-1995 Aladdin Enterprises, Menlo Park, CA. All rights reserved. Ghostscript comes with NO WARRANTY: see the file COPYING for details.
A specific blank window will be opened at the same time with the appearence of this command prompt. If we want to dismiss the ghostscript session, all we have to do is to issue quit command at GS> prompt. EOF (Ctrl-D) works also for the same purpose.
Ghostscript can execute the commands by getting them from a file also. In this case we open a file named, for example, sample.ps . All commands to be executed by ghostscript are written in this file. Hence we can call the content of this file a PostScript program. The entire content of this program or its individual commands will be consecutively executed by ghostscript if we issue the following command at the shell prompt of the xterm window of linux
and the display (if the program aims at the creation of a display, of course. In fact, PostScript can be used for other purposes like mathematical calculations, stack operation etc. We will mention them in future articles of this series) will be appearing on the ghostscript window. If the program produces more pages than a single one then the ghostscript window shows the first page and a showpage prompt appears at the ghostscript commandline requesting enter key pressing for the next page.
PostScript uses Reverse Polish Notation (RPN - like HP pocket calculators). In other words parameters for a command are given before the command. The commands are separated by blank spaces. It uses stack operations for data processing and command execution. There are four available stacks in PostScript usage: the operand, dictionary, execution and graphics state stacks. The operand stack holds arbitrary PostScript objects that are the operands and results of PostScript operators being executed. We can give some examples from arithmetical operations. For instance,
produces 40 since 20 30 add creates 50 and sub produces 40 by using 50 together with 10. mul (multiplication) and div (division) work in the same way. The name '=' is associatedwith a procedure that pops one object from the operand stack and writes a text representation of its value to the standard ouput file, followed by a newline. == has a similar action but it writes syntactic representation of its operand to the standard output file. pop command removes the top element from the operand stack and discards it. We will mention about the stacks in a more detailed manner later articles of this series.
How do we use PostScript for drawing figures?
We can start drawing figures through PostScript by considering the geometrical structure of the page to be designed. The locations of the points on a page are denoted via pixel units which are one seventy second of an inch in PostScript language. The left bottom side of the rectangular page is assumed to be the location which has the (0,0) coordinates and the horizontal and the vertical sizes of the page are defined as 612 and 792 respectively. These sizes are for the letter type of papers. There are other possibilities for the definition of the paper sizes like
These are regular gs commands. The command 'a4' will resize your drawing sheet to the appropriate size.
The paper size definition can be found in the initialization file whose name is gs_statd.ps. It can be found in /usr/lib/ghostscript for Slackware. You can define any non-standard paper size by making convenient additions and modifications on this file as we will mention later in this series of articles. Here we assume that we use the default paper type letter in this presentation.
The second step after taking the paper in desired sizes in drawing a figure is to locate the curser at the beginning of the drawing. This can be accomplished by issuing the command
where x and y denote respectively the horizontal and vertical coordinates of the point where the cursor will be located. x and y are pure numbers and considered in pixel units. As you can see the functional structure of the PostScript is a little bit different from the other programming languages like C, Fortran. moveto is the command which takes the action, in other words it moves the cursor to somewhere whose location is given by x and y. Since PostScript uses a stack the parameters are given consecutively to the stack first. Then the command is given. When it enters the stack it accepts the previous two items as its parameters. The syntax here is different for the end user who is familiar with languages like C, Fortran. For this reason we have emphasized on this topic here. As a conclusion we can say that each command which needs some parameters must be given after its parameters.
Now we are ready to start to draw the figure. Let us start with a rather simple figure, just a straight line segment. To draw this, all we have to do is to issue the following command
where xx and yy denote the location of the endpoint of the line segment. Its beginning point is the present location of the cursor, x and y . Hence, this command constructs a straight line segment from x y to xx yy . The actual drawing necessitates the path definition newpath and stroke command. Now let us write a PostScript program to draw a rectangle. This can be done by using the information given above. The program which is assumed saved in the file sample1.ps can be given as follows
100 100 lineto stroke
Although we have given each command in separate lines, this is not really necessary. We could give them in the same line by inserting a blank space between consecutive commands as we mention before.
PostScript has commenting facility like the other programming languages. Whole material which follows a percentage sign in a line is interpreted as comment by the interpreter.
% Drawing the rectangle
100 100 lineto stroke
If we now issue gs sample1.ps command at the prompt of the xterm window then the usual ghostscript window appears containing the desired display of the rectangle. We do not need to invoke gs interpreter at every time of displaying. In fact,
command does the same thing through the GS> prompt.
The stroke command tells to the interpreter to draw the figure. For the above program the ghostscript window displays the rectangle with edges of 200 and 150 points in horizontal and vertical directions.
The straight lines do not need to be vertical or horizontal. They can be constructed in any direction.
As you will see when we display the result through ghostscript, this program creates a triangle. You can create any kind of figures which are composed of broken lines or line segments by using moveto and linetocommands.
There are two more commands to be used in the above figure constructions. These are rmoveto and rlineto . They need two parameters and can be used as follows
where x and y are the horizontal and vertical distances between the initial and final points of each action. ‘r’ in rmove and rlineto stands for ‘relative’. In other words the first command moves the cursor x units horizontally to right and y units to up from its present location. The second command behaves similarly but it draws a line and moves the cursor to the final point instead of only moving cursor. These are referring commands and the parameters are given by taking the initial location as the reference point.
All above examples use a default linewidth for the drawing. This value is 1 pixel. However user can define the line width of the drawing at anywhere in the program. This can be done by issuing the command
where x denotes the line width in pixels. The effect of this command continues until the next line width setting in the program. There is no limitation for the number of line width settings in a program.
Of course, the drawing in PostScript is not limited to straight lines. The circular arcs can be also produced. For this purpose we can use the following command
where x, y, r, a and b stand for the horizontal and vertical coordinates of the center of the circular arc, the radius of the arc, the angle between the positive part of the horizontal axis and the central rays which pass through the beginning and the final points of the arc. The angles are measured counterclockwise. If the beginning point of the arc is not the present location of the cursor, then a straight line between the currentpoint (the location of the cursor) and the beginning point arc is also added to the figure. To understand the situations you can have a look at the display of the following PostScript program.
100 200 100 0 75 arc
400 500 200 20 50 arc
Therefore we must be careful to place the cursor at the beginning point of the arc if do not want the extra line mentioned above. However there is another way to get rid of this effect. In fact, the currentpoint can be made empty valued. In other words at the beginning of the path it has no parameter values. There is no assignment for the location of the cursor. Once the drawing is started the final point of the path becomes the current point. If we issue newpath command then PostScript erases the assignment for the cursor point and treats as if the drawing will start just from that instance. Therefore the above program can be modified by replacing the fifth line with a line which contains only newpath command. If this is done and displayed then the same output, except the extra line segment, of the above program will be obtained.
A path is begun by executing the newpath operator. This initializes the current path to be empty. The path is then built up via execution of some commands for adding segments to the current path.
arc command can be used to draw a full circle. It is sufficient to give the beginning and the final angles of the arc as 0 and 360 respectively. If this is done under a newpath a complete circle is obtained. arc command can be used to produce ellipses also. This can be accomplished by using scaling property of PostScript. The user can rescale of the horizontal and vertical units separately via the following command.
where x and y denote respectively the horizontal and vertical scaling factors. This means that the case where these factors are equal to 1 creates no effect on the drawing. The effect of the scaling is maintained until the next scaling command is issued. The next issued scaling command does not remove the effect of the previous one but it combines its own effect with the previous one. If we assume that the previous scaling command parameter has the scaling factors x1, y1 while the next scaling command parameter has x2, y2 factors then the combined effect of these commands has the scaling factors x1*x2, y1*y2 . This point must not be kept far from the eyes to avoid undesired results in the displays, such that some paths may slide out of the paper surface. PostScript assumes the nonexistence of scaling by default. The following PostScript program which is assumed to be saved in the file sample4.ps forms an example to explain the scaling.
200 200 100 0 360 arc
200 300 50 0 360 arc
100 150 40 0 360 arc
As can be noticed, the scaling affects each size including the line width. The line widths of the ellipses and the circle created by the above program are different due to this reason.
PostScript also has two other commands for arc drawing. One of them, arcn , is mainly same with arc except the drawing direction. arcn draws arc clockwise. The third arc drawing command draws a circular arc which is tangent to two given lines at the endpoints. It can be issued as follows.
x1 y1 x2 y2 r arcto xt1 yt1 xt2 yt2
where xt1, yt1, xt2, yt2 denote the horizontal and the vertical coordinates of the arc while the end points of the tangent lines have the the values x0, y0, x1, y1 and x1, y1, x2, y2 respectively and r stands for the radius of the arc. If the path is not new or the current point does not coincide with the beginning of the arc then a line joining the current point and the beginning point of the arc is added to the path. At the end of the drawing the currentpoint becomes xt2, yt2 .
PostScript has also a Bezier algorithm based command which can be effectively used in the interpolation or extrapolation of a given data for plotting. This command is curveto and can be used to form the plots based on the interpolation or extrapolation of a given set of data. The command can be used as follows.
x1 y1 x2 y2 x3 y3 curveto
where the curve starts at the current point whose coordinates are assumed to be x0, y0 . It is tangent to the line between the points x0, y0 and x1, y1 at the beginning point. The curve ends at the point x3, y3 and is tangent to the line between x2, y2 and x3, y3 . By default all these four points are assumed to be different and they determine the shape of the figure.
Writing facilities in PostScript
PostScript has various fonts which are used as standard fonts for desk-top publishing. It has also font creating facilities which can be accessed by defining dictionary stacks where fonts are available. The following PostScript program can be given as an example.
(I love PostScript!) show
(I love PostScript!) show
(I love PostScript!) show
(I love PostScript!) show
(I love PostScript!) show
(I love PostScript!) show
As can be extracted from the program findfont command is used for getting an access to the desired font structure. The name of the font starts with / and is given to the command as a preceding parameter (where / tells the interpreter to push this value on the stack ‘as is’. When we get into the details of stack operations later this point will be more clear. After the selection of the command the scaling is defined through the scalefont command. The scaling factor is given as a preceding number to this command. After scaling of the font, the command setfont makes the font ready for future usage in the program. After we locate the cursor through the moveto command with appropriate parameters, the text material encompassed by the parenthesis is given a parameter for the show command. The showpage command finalizes the displaying of the written material. The above program uses different fonts in type and size for the same text located at different positions. The number of the avaliable fonts for PostScript can be found by searching the locations of the fonts in the tree structure of the linux system you use. The text can be adjusted through lines, curves and by some other tool. So any kind of writing, in principle, is possible. It is just a matter of design.
Painting and color usage in PostScript
PostScript language is equipped with several facilities to paint figures or create colorful pictures. Let us start by mentioning the coloring commands first. PostScript uses black as the default color unless a color specification command is issued. Hence the output of the all previous programs were black and white pictures. To use color in the output PostScript can use three different coloring command. The first one is based on the rgb color format. In this format each color is assumed to be composed of three main colors: red, green and blue. The color components can be given by individual intensity parameters which can take the values between 0 and 256. The intensity parameters can accept the decimal fractional values up to three digit precision like 111.223. Therefore the command expected by PostScript must be given as follows.
x y z setrgbcolor
where x,y,z are the intensity parameters for the red, green and blue components and setrgbcolor is the command. In this convention 1 0 0 setrgbcolor creates red color while 0 1 0 setrgbcolor creating green. Black corresponds to the case where all intensity parameters take the value of 1. Color setting command continues to affect every drawing and painting until the next color setting command is issued. When this happens the effect of the first setting is completely removed and the new setting dominates everything. The number of usage for the color setting is unlimited. By approriately using the color settings you can create your pictures just as you want. It is a matter of art and up to you.
The second color setting facility is based on a four component color format. This is called cmyk color format. The four basic color components are cyan, magenta, yellow and black respectively. Each color component contributes the final color according to an intensity parameter which can vary between 0 and 1. The corresponding PostScript command is therefore as follows
w x y z setcmykcolor
where w, x, y, z are the intensity parameters for the color components cyan, magenta, yellow and black respectively. The fractional decimal values can also be used for intensity parameters. This command also continues its effect on everything until the next command is issued. When this is done the new setting overdominates the preceding setting. There is no limitation on the number of usage for this command in a program.
Third command can be used as follows
x y z sethsbcolor
where x, y, z stand for the intensity paremeters of three different properties of the color. First one corresponds to hue which determines the location of the color in the spectrum of the light. The second one, saturation and the third one, brightness corresponds to the saturation and the brightness of the color. This format is preferred when the location of the color in the spectrum via a loop or the brightness and/or saturation become the properties to be controlled. The reader who is not familiar to hsbcolor he/she can check the use of the xfig facility under linux.
The most important PostScript command for painting is fill and closepath . The following example program which is assumed to be saved in the file sample6.ps clarifies important aspects of the painting and coloring through PostScript.
1 1 0 0 setcmykcolor
1 0.5 0.8 0 setcmykcolor
1 0 0 setrgbcolor
100 200 100 0 75 arc
400 500 200 20 50 arc
0 0 1 0.2 setcmykcolor
200 200 100 0 360 arc
1 0 0 setrgbcolor
200 300 50 0 360 arc
gsave fill grestore stroke
0 1 0 setrgbcolor
100 150 40 0 360 arc
gsave fill grestore stroke
where closepath command closes an open path by joining two end points by a straight line while fill serves to fill inside of the closed path with the current color.
PostScript can also create grey tones. This can be done through the command
where x is the intensity of the graycolor and its value can change from 0, which corresponds to black, to 1 which corresponds to white. The following program which is saved under the name sample7.ps is constructed in a sufficiently self=explanatory manner.
Before the completion of this presentation we can recommend to write more complicated and comprehensive programs for the users who find PostScript as an enthusisastic tool. In the next articles of these series more details about the PostScript language. All questions and recommendations are welcome for our presentations. We shall give sufficient credit to these in our coming articles.
The author thanks to Oliver Thilmann for his very helpful comments for the organization and presentation of this article.
Consult the books of Adobe Systems Inc. published by Addison-Wesley: PostScript Language
(Three volumes: Tutorial and Cookbook, Language Reference, Program Design)
Using the Adobe PostScript driver, you can use DWGs with an array of page layout programs and archive tools such as the Adobe Acrobat Portable Document Format (PDF).
You can use the non-system PostScript driver to plot drawings to PostScript printers and PostScript files. Use the PS file format for printers and the EPS file format for files. If you plot to a hardware port, PS output is automatic. If you plot to a file and plan to copy the file to a printer, configure for PS output.
Use the custom Properties dialog box in the Plotter Configuration Editor to customize the output. To display this dialog box, on the Device and Document Settings tab, in the tree view, select Custom Properties. Then under Access Custom Dialog, click the Custom Properties button.
The PostScript driver supports three types of PostScript.
Level 1: Use for most plotters.
Level 1.5: Use for plotters that support color images.
Level 2: If your plotter supports Level 2 PostScript, use to produce smaller files that print more rapidly.
The Tokenize PostScript Code and Compression options in the PostScript Custom Properties dialog box reduce output file size and improve printing speed on devices that support these options. If you have problems printing, try clearing all the options. If you successfully print with no optimizations, you can try turning the options on one at a time to determine the options your printer supports.
Some desktop publishing applications only support Level 1 PostScript. If you have problems using your EPS files, try a lower PostScript level and turn off the optimizations just described.
Including a preview thumbnail in your EPS file makes the file substantially larger but allows quick preview by many applications. The WMF preview is for Windows; the EPSF preview is for Macintosh and other platforms.
Including both preview images can triple your file size.
Hart is the most important figure in Jurisprudence scholarship
Hart’s Postscript has not been the subject of a study of this kind before
The book includes all of the most active legal theorists currently writing on Hart’s work
Essays on the Postscript to The Concept of Law
Edited by Jules Coleman
Published posthumously, the second edition of The Concept of Law contains one important addition to the first edition, a substantial Postscript, in which Hart reflects upon some of the central concerns that have been expressed about the book since its publication in 1961.
Essays on the Postscript to The Concept of Law
Edited by Jules Coleman
Table of Contents
1. Two Views of the Nature of The Theory of Law: A Partial Comparison, Joseph Raz
2. Herbert Hart and the Semantic Sting, Timothy Endicott
3. Hart’s Semantics, Nicos Stavropoulos
4. Incorporationism, Conventionality and the Practical Difference Thesis, Jules L. Coleman
5. Hart’s Way Out, Scott Shapiro
6. Legal Conventionalism, Andrei Marmor
7. The Model of Social Facts, Benjamin Zipursky
8. Law’s Claim of Legitimate Authority, Kenneth Himma
9. Hart’s Methodological Positivism, Stephen Perry
10. Realism, Hart Positivism, and Conceptual Analysis, Brian Leiter
11. The Political Question of the Concept of Law, Liam Murphy
12. Normative (or Ethical) Positivism, Jeremy Waldron
Essays on the Postscript to The Concept of Law
Edited by Jules Coleman
Jules Coleman is Professor of Law at Yale Law School
Jules L. Coleman
Also of Interest
Markets, Morals, and the Law
Reason in Action
The Practice of Principle
Griffin on Human Rights
Philosophy of Nonviolence
The Federal Courts
Peter Charles Hoffer, Williamjames Hull Hoffer, and N. E. H. Hull
Shaping the Normative Landscape
Can Microfinance Work?
THE GLOBAL COMMUNITY YEARBOOK OF INTERNATIONAL LAW AND JURISPRUDENCE 2013
Giuliana Ziccardi Capaldo
Francoise Baylis and Carolyn McLeod
Law as a Leap of Faith
Rwanda and the Moral Obligation of Humanitarian Intervention
Joshua James Kassner
Oxford English Dictionary
English Language Teaching
University of Oxford
Arts & Humanities
Dictionaries & Reference
Medicine & Health
Science & Mathematics
Oxford University Press is a department of the University of Oxford. It furthers the University’s objective of excellence in research, scholarship, and education by publishing worldwide.
Ghostscript is an interpreter for the PostScript language. A PostScript interpreter usually takes as input a set of graphics commands. The output is usually a page bitmap which is then sent to an output device such as a printer or display. PostScript is embedded in many printers.
Ghostscript has several main uses:
Display a PostScript or PDF file (avoid killing trees).
Convert a PostScript file to a PDF (or vice versa)
Display a PostScript file to decide if you really need to print it (reduce the number of trees killed).
Print a PostScript file to a non-PostScript printer (kill more trees).
An example of a very simple PostScript file is: The first line is a PostScript comment. It is ignored by the PostScript interpreter, but enables other programs to recognise that the file contains PostScript commands. The second line says to find the Helvetica font, scale it to 72 points high (1 inch) and then set it as the current font. The third line moves the current point to 1 inch in from the left and bottom edges of the page. The fourth line draws the text into the page bitmap at the current point. The final line causes the page bitmap to be output to paper or the display.
The information below assumes the use of GNU Ghostscript 6.51. Other versions of Ghostscript are similar. The Ghostscript program is typically found in /usr/local/bin/gs
Ghostscript needs some initialization files in /usr/local/lib/ghostscript/6.51
and some fonts in /usr/local/lib/ghostscript/fonts.
The documenation files are in /usr/local/lib/ghostscript/6.51/doc
and some example PostScript files are in /usr/local/lib/ghostscript/6.51/examples.
Displaying a PostScript file
So now you know how to display a PostScript file. The same instructions apply for .pdf files as well. Some example PostScript files that come with Ghostscript are colorcir.ps, chess.ps and tiger.ps. These should be in the examples/ directory under the ghostscript tree.
Printing a PostScript file
To get a list of available printer devices, start Ghostscript for displaying, then type: The destination for the printed output can be specified on the command line. To output to the file out.prn, add -sOutputFile="out.prn" somewhere before the name of the PostScript file. To pipe the output to the lpr program, use -sOutputFile="\|lpr queuename"
A better way
If you are like me, you get sick of typing the long commands above. A program called gv and several derivatives exist for X11 on Unix or VMS. This allows you to display page 20 without having to display pages 1, 2, 3, 4, . 20. You can also print selected pages.
You may also find useful the ggv application distributed with the GNOME desktop environment.
This page was written by Russell Lang and Ralph Giles.
Please send FSF & GNU inquiries & questions to firstname.lastname@example.org. There are also other ways to contact the FSF.
Please send comments on these web pages to email@example.com, send other questions to firstname.lastname@example.org.
Copyright (C) 1997, 1998, 2001, 2005 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
truetype fonts, postscript fonts, font technology, font support, linotype, typography, fonts, typefaces, download fonts, buy fonts, font
PostScript and TrueType
PostScript Type 1 fonts can also be called outline fonts. They are a special form of the PostScript programming language, themselves building programs of their own, namely the font software. A font in the PostScript language contains an organized collection of procedures to describe the glyph forms. See the PostScript Language Reference Manual for more detailed information. Different font programs contain different amounts of information, gathered together in the so-called ?dictionary?. The dictionary saves the obligatory and optional entries and serves the PostScript interpreter as a data object in order to access all font functions.
The TrueType technology is made up of two components: fonts in TrueType font format and the TrueType rasterizer. Both are necessary to display and print TrueType fonts on computer systems. TrueType is compatible with both Apple and Windows systems, however, a separate TrueType font file must be created for each operating system.
2. If the outline falls exactly on the middle of a pixel, the pixel will be turned on.
So which of the two font formats is “better”? The answer is anything but simple and must be seen from a variety of angles. Both formats, TrueType and Type1, consist of algorithms or instructions with which an outline font can be rasterized in pixels for display. The main differences between the two formats are of technical and philosophical nature, as well as dependent upon various corporate policies.
This Font Technology Feature is an excerpt from:
Ivir, Milo. ’Entwicklung digitaler Schrifttechnologien und ihre Einflußnahme auf die Typografie im Zeitalter des elektronischen Publizierens’ (The Development of Digital Font Technologies and their influence on Typography in the Age of Electronic Publishing). Diploma thesis, Institute for Technology and Print Planning, College of Art, Berlin, 1998.