2273 lines · 85.6 KB · HTML
RawDownload
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Ghostscript and the PostScript language</title><!-- $Id: Language.htm,v 1.98 2005/10/20 19:46:23 ray Exp $ --><!-- Originally: language.txt --><link rel="stylesheet" type="text/css" href="gs.css" title="Ghostscript Style"></head> <body><!-- [1.0 begin visible header] ============================================ --> <!-- [1.1 begin headline] ================================================== --> <h1>Ghostscript and the PostScript language</h1> <!-- [1.1 end headline] ==================================================== --> <!-- [1.2 begin table of contents] ========================================= --> <h2>Table of contents</h2> <blockquote><ul><li><a href="#Capabilities">Ghostscript's capabilities in relation to PostScript</a><li><a href="#Implementation_limits">Implementation limits</a><ul><li><a href="#Architectural_limits">Architectural limits</a><li><a href="#Typical_memory_limits">Typical memory limits in LanguageLevel 1</a><li><a href="#VM_consumption">Other differences in VM consumption</a></ul><li><a href="#Additional_operators">Additional operators in Ghostscript</a><ul><li><a href="#Graphics_and_text">Graphics and text operators</a><ul><li><a href="#Transparency">Transparency</a><ul><li><a href="#Transparency_graphics_state_operators">Graphics state operators</a><li><a href="#Transparency_rendering_stack_operators">Rendering stack operators</a><li><a href="#Transparency_ImageType">New ImageType</a></ul><li><a href="#Graphics_state">Other graphics state operators</a><li><a href="#Path">Path operators</a><li><a href="#Painting">Painting operators</a><li><a href="#Character">Character operators</a></ul><li><a href="#Other">Other operators</a><ul><li><a href="#Mathematical">Mathematical operators</a><li><a href="#Dictionary">Dictionary operators</a><li><a href="#String">String and name operators</a><li><a href="#Relational">Relational operators</a><li><a href="#File">File operators</a><li><a href="#Virtual_memory">Virtual memory operators</a><li><a href="#Miscellaneous">Miscellaneous operators</a><li><a href="#Device">Device operators</a></ul></ul><li><a href="#Filters">Filters</a><ul><li><a href="#Standard_filters">Standard filters</a><li><a href="#Non_standard_filters">Non-standard filters</a><li><a href="#Unstable_filters">Unstable filters</a></ul><li><a href="#Device_parameters">Device parameters</a><li><a href="#User_parameters">User parameters</a><li><a href="#Miscellaneous_additions">Miscellaneous additions</a><ul><li><a href="#Extended_semantics_of_run">Extended semantics of 'run'</a><li><a href="#DecodingResources">Decoding resources</a><li><a href="#CIDDecodingResources">CIDDecoding resources</a><li><a href="#GlyphNames2Unicode">GlyphNames2Unicode</a><li><a href="#MultipleResourceDirectories">Multiple Resource directories</a></ul></ul></blockquote> <!-- [1.2 end table of contents] =========================================== --> <!-- [1.3 begin hint] ====================================================== --> <p>For other information, see the <a href="Readme.htm">Ghostscriptoverview</a>. <!-- [1.3 end hint] ======================================================== --> <hr> <!-- [1.0 end visible header] ============================================== --> <!-- [2.0 begin contents] ================================================== --> <h2><a name="Capabilities"></a>Ghostscript's capabilities in relation to PostScript</h2> <p>The Ghostscript interpreter, except as noted below, is intended to executeproperly any source program written in the (LanguageLevel 3)<b>PostScript</b> language as defined in the <cite>PostScriptLanguage Reference, Third Edition</cite> (ISBN 0-201-37922-8) published byAddison-Wesley in mid-1999.  However, the interpreter is configurable inways that can restrict it to various subsets of this language.Specifically, the base interpreter accepts the Level 1 subset of thePostScript language, as defined in the first edition of the <cite>PostScriptLanguage Reference Manual</cite> (ISBN 0-201-10174-2) Addison-Wesley 1985,plus the file system, version 25.0 language, and miscellaneous additionslisted in sections A.1.6, A.1.7, and A.1.8 of the Second Editionrespectively, including allowing a string operand for the"<b><tt>status</tt></b>" operator.  The base interpreter may be configured(see the <a href="Make.htm">documentation on building Ghostscript</a> forhow to configure it) by adding any combination of the following: <ul><li>The ability to process PostScript Type 1 fonts.  This facility isnormally included in the interpreter. <li>The CMYK color extensions listed in section A.1.4 of the Second Edition(including <b><tt>colorimage</tt></b>).  These facilities are availableonly if the <b><tt>color</tt></b>, <b><tt>dps</tt></b>, or<b><tt>level2</tt></b> feature was selected when Ghostscript was built. <li>The Display PostScript extensions listed in section A.1.3 of the SecondEdition, but excluding the operators listed in section A.1.2.  Thesefacilities are available only if the <b><tt>dps</tt></b> feature or the<b><tt>level2</tt></b> feature was selected when Ghostscript was built. <li>The composite font extensions listed in section A.1.5 of the SecondEdition, and the ability to handle Type 0 fonts.  These facilities areavailable only if the <b><tt>compfont</tt></b> feature or the<b><tt>level2</tt></b> feature was selected when Ghostscript was built. <li>The ability to load TrueType fonts and to handle PostScript Type 42(encapsulated TrueType) fonts.  These facilities are available only if the<b><tt>ttfont</tt></b> feature was selected when Ghostscript was built. <li>The PostScript Level 2 "filter" facilities except the<b><tt>DCTEncode</tt></b> and <b><tt>DCTDecode</tt></b> filters.  Thesefacilities are available only if the <b><tt>filter</tt></b>,<b><tt>dps</tt></b>, or <b><tt>level2</tt></b> feature was selected whenGhostscript was built. <li>The PostScript Level 2 <b><tt>DCTEncode</tt></b> and<b><tt>DCTDecode</tt></b> filters.  These facilities are available only ifthe <b><tt>dct</tt></b> or <b><tt>level2</tt></b> feature was selected whenGhostscript was built. <li>All the other PostScript Level 2 operators and facilities listed insection A.1.1 of the Second Edition and not listed in any of the otherA.1.n sections.  These facilities are available only if the<b><tt>level2</tt></b> feature was selected when Ghostscript was built. <li>All PostScript LanguageLevel 3 operators and facilities listed in theThird Edition, except as noted below.  These facilities are available onlyif the <b><tt>psl3</tt></b> feature was selected when Ghostscript was built. <li>The ability to recognize DOS EPSF files and process only the PostScriptpart, ignoring bitmap previews or other information.  This facility isavailable only if the <b><tt>epsf</tt></b> feature was selected whenGhostscript was built.</ul> <p>Ghostscript currently does not implement the following PostScriptLanguageLevel 3 facilities: <ul><li>Native <b><tt>Separation</tt></b> and <b><tt>DeviceN</tt></b> colorspaces -- the alternate space is always used. <li>Settable <b><tt>ProcessColorModel</tt></b> for page devices, except fora very few special devices. <li><b><tt>IODevice</tt></b>s other than <b><tt>%stdin</tt></b>,<b><tt>%stdout</tt></b>, <b><tt>%stderr</tt></b>, <b><tt>%lineedit</tt></b>,<b><tt>%statementedit</tt></b>, <b><tt>%os%</tt></b>, and (if configured)<b><tt>%pipe%</tt></b> and <b><tt>%disk0%</tt></b> through <b><tt>%disk0%</tt></b>.</ul> <p>Ghostscript can also interpret files in the Portable Document Format (PDF)1.3 format defined in the <ahref="http://partners.adobe.com/asn/developer/PDFS/TN/PLRM.pdf"><em>PortableDocument Format Reference Manual</em> Version 1.3</a> of March 11, 1999,distributed by <a href="http://www.adobe.com/">Adobe SystemsIncorporated</a>, except as noted below.  This facility is available only ifthe <b><tt>pdf</tt></b> feature was selected when Ghostscript was built. <p>Ghostscript currently does not implement the following PDF 1.3 facilities: <ul><li>Native <b><tt>Separation</tt></b> and <b><tt>DeviceN</tt></b> colorspaces, as noted above for PostScript. <li>Native <b><tt>ICCBased</tt></b> color spaces -- these too always use thealternate space.</ul> <p>Ghostscript also includes a number of<a href="#Additional_operators">additional operators</a> defined below thatare not in the PostScript language defined by Adobe. <hr> <h2><a name="Implementation_limits"></a>Implementation limits</h2> <p>The implementation limits show here correspond to those in Tables B.1 andB.2 of the Second and Third Editions, which describe the quantities fully.Where Ghostscript's limits are different from those of Adobe'simplementations (as shown in the Third Edition), Adobe's limits are alsoshown. <h3><a name="Architectural_limits"></a>Architectural limits</h3> <blockquote><table cellpadding=0 cellspacing=0><tr><th colspan=7 bgcolor="#CCCC00"><hr><font size="+1">Architectural limits (corresponds to Adobe table B.1)</font><hr><tr valign=bottom>	<th align=left>Quantity	<td>&nbsp;&nbsp;	<th align=left>Limit	<td>&nbsp;&nbsp;	<th align=left>Type	<td>&nbsp;&nbsp;	<th align=left>Adobe<tr>	<td colspan=7><hr><tr valign=top>	<td>integer	<td>&nbsp;	<td>32-bit	<td>&nbsp;	<td>twos complement integer	<td>&nbsp;	<td>&nbsp;<tr valign=top>	<td>real	<td>&nbsp;	<td>single-precision	<td>&nbsp;	<td>IEEE float	<td>&nbsp;	<td>&nbsp;<tr valign=top>	<td>array	<td>&nbsp;	<td>65535	<td>&nbsp;	<td>elements	<td>&nbsp;	<td>&nbsp;<tr valign=top>	<td>dictionary	<td>&nbsp;	<td>65534	<td>&nbsp;	<td>elements	<td>&nbsp;	<td>65535<tr valign=top>	<td>string	<td>&nbsp;	<td>65535	<td>&nbsp;	<td>characters	<td>&nbsp;	<td>&nbsp;<tr valign=top>	<td>name	<td>&nbsp;	<td>16383	<td>&nbsp;	<td>characters	<td>&nbsp;	<td>127<tr valign=top>	<td>filename	<td>&nbsp;	<td>128*	<td>&nbsp;	<td>characters	<td>&nbsp;	<td>&nbsp;<tr valign=top>	<td><b><tt>save</tt></b> level	<td>&nbsp;	<td>none	<td>&nbsp;	<td>(capacity of memory)	<td>&nbsp;	<td>15<tr valign=top>	<td><b><tt>gsave</tt></b> level	<td>&nbsp;	<td>none	<td>&nbsp;	<td>(capacity of memory)	<td>&nbsp;	<td>13</table></blockquote> <p>* The limit on the length of a file name is 128 characters if the namestarts with a %...% IODevice designation, or 124 characters if it does not. <h3><a name="Typical_memory_limits"></a>Typical memory limits in LanguageLevel 1</h3> <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=7 bgcolor="#CCCC00"><hr><font size="+1">Memory limits (corresponds to Adobe table B.2)</font><hr><tr valign=bottom>	<th align=left>Quantity	<td>&nbsp;&nbsp;	<th align=left>Limit	<td>&nbsp;&nbsp;	<th align=left>Type	<td>&nbsp;&nbsp;	<th align=left>Adobe<tr>	<td colspan=7><hr><tr valign=top>	<td><b><tt>userdict</tt></b>	<td>&nbsp;	<td>200	<td>&nbsp;	<td>&nbsp;	<td>&nbsp;	<td>&nbsp;<tr valign=top>	<td><b><tt>FontDirectory</tt></b>	<td>&nbsp;	<td>100	<td>&nbsp;	<td>&nbsp;	<td>&nbsp;	<td>&nbsp;<tr valign=top>	<td>operand stack	<td>&nbsp;	<td>800	<td>&nbsp;	<td>&nbsp;	<td>&nbsp;	<td>500<tr valign=top>	<td>dictionary stack	<td>&nbsp;	<td>20	<td>&nbsp;	<td>&nbsp;<tr valign=top>	<td>execution stack	<td>&nbsp;	<td>250	<td>&nbsp;	<td>&nbsp;<tr valign=top>	<td>interpreter level	<td>&nbsp;	<td>none	<td>&nbsp;	<td>(capacity of memory)	<td>&nbsp;	<td>10<tr valign=top>	<td>path	<td>&nbsp;	<td>none	<td>&nbsp;	<td>(capacity of memory)	<td>&nbsp;	<td>1500<tr valign=top>	<td>dash	<td>&nbsp;	<td>11	<td>&nbsp;	<td>&nbsp;<tr valign=top>	<td>VM	<td>&nbsp;	<td>none	<td>&nbsp;	<td>(capacity of memory)	<td>&nbsp;	<td>240000<tr valign=top>	<td>file	<td>&nbsp;	<td>none	<td>&nbsp;	<td>(determined by operating system)	<td>&nbsp;	<td>6<tr valign=top>	<td>image	<td>&nbsp;	<td>65535	<td>&nbsp;	<td>values (samples × components)<br>for1-, 2-, 4-, or 8-bit samples	<td>&nbsp;	<td>3300<tr valign=top>	<td>&nbsp;	<td>&nbsp;	<td>32767	<td>&nbsp;	<td>values for 12-bit samples	<td>&nbsp;	<td>3300</table></blockquote> <h3><a name="VM_consumption"></a>Other differences in VM consumption</h3> <p>Packed array elements occupy either 2 bytes or 8 bytes.  The averageelement size is probably about 5 bytes.  Names occupy 12 bytes plus thespace for the string.<p>The garbage collector doesn't reclaim portions of arrays obtained with <tt>getinterval</tt>, rather it collects entire arrays.<hr> <h2><a name="Additional_operators"></a>Additional operators in Ghostscript</h2> <h3><a name="Graphics_and_text"></a>Graphics and text operators</h3> <h4><a name="Transparency"></a>Transparency</h4> <p>Ghostscript provides a set of operators for implementing the transparencyand compositing facilities of PDF 1.4.  These are defined only if the<b><tt>transpar</tt></b> option was selected when Ghostscript was built.  Wedo not attempt to explain the underlying graphics model here: for details,see <ahref="http://partners.adobe.com/asn/developer/technotes.html#acrobat-pdf" class="offsite">AdobeTechnical Note</a> #5407, "<ahref="http://partners.adobe.com/asn/developer/acrosdk/DOCS/PDF_Transparency.pdf" class="offsite">Transparencyin PDF</a>". Note, however, thatGhostscript's model generalizes that of PDF 1.4 in that Ghostscriptmaintains separate alpha and mask values for opacity and shape, rather thana single value with a Boolean that says whether it represents opacity orshape.  EVERYTHING IN THIS SECTION IS SUBJECT TO CHANGE. <h5><a name="Transparency_graphics_state_operators"></a>Graphics stateoperators</h5> <dl><dt><b><tt>&lt;modename&gt; .setblendmode -</tt></b><dd>Sets the blending mode in the graphics state.  If the mode name is notrecognized, causes a <b><tt>rangecheck</tt></b> error.  The initial value ofthe blending mode is <b><tt>/Compatible</tt></b>.</dl> <dl><dt><b><tt>- .currentblendmode &lt;modename&gt;</tt></b><dd>Returns the current blending mode.</dl> <dl><dt><b><tt>&lt;0..1&gt; .setopacityalpha -</tt></b><dd>Sets the opacity alpha value in the graphics state.The initial opacity alpha value is 1.</dl> <dl><dt><b><tt>- .currentopacityalpha &lt;0..1&gt;</tt></b><dd>Returns the current opacity alpha value.</dl> <dl><dt><b><tt>&lt;0..1&gt; .setshapealpha -</tt></b><dd>Sets the shape alpha value in the graphics state.The initial shape alpha value is 1.</dl> <dl><dt><b><tt>- .currentshapealpha &lt;0..1&gt;</tt></b><dd>Returns the current shape alpha value.</dl> <dl><dt><b><tt>&lt;bool&gt; .settextknockout -</tt></b><dd>Sets the text knockout flag in the graphics state.The initial value of the text knockout flag is <b><tt>true</tt></b>.</dl> <dl><dt><b><tt>- .currenttextknockout &lt;bool&gt;</tt></b><dd>Returns the current text knockout flag.</dl> <h5><a name="Transparency_rendering_stack_operators"></a>Rendering stackoperators</h5> <p>The interpreter state is extended to include a (per-context) rendering stackfor handling transparency groups and masks (generically, "layers").  Groupsaccumulate a full value for each pixel (paint plus transparency); masksaccumulate only a coverage value.  Layers must be properly nested, i.e., the'end' or 'discard' operator must match the corresponding 'begin' operator. <p>Beginning and ending layers must nest properly with respect to<b><tt>save</tt></b> and <b><tt>restore</tt></b>: <b><tt>save</tt></b> and<b><tt>restore</tt></b> do not save and restore the layer stack.  Currently,layers are not required to nest with respect to <b><tt>gsave</tt></b> and<b><tt>grestore</tt></b>, except that the device that is current in thegraphics state when ending a layer must be the same as the device that wascurrent when beginning the layer.  THIS AREA IS SUBJECT TO CHANGE. <dl><dt><b><tt>&lt;paramdict&gt; &lt;llx&gt; &lt;lly&gt; &lt;urx&gt; &lt;ury&gt;.begintransparencygroup -</tt></b><dd>Begins a new transparency group.  The <b><tt>ll/ur</tt></b> coordinatesare the bounding box of the group in the current user coordinate system.<b><tt>paramdict</tt></b> has the following keys:<dl><dt><b><tt>/Isolated</tt></b><dd>(optional) Boolean; default value = <b><tt>false</tt></b>.<dt><b><tt>/Knockout</tt></b><dd>(optional) Boolean; default value = <b><tt>false</tt></b>.

Lines 1–500 of 2273.