📄 language.htm
字号:
<html>
<head>
<title>The relationship between Ghostscript and PostScript</title>
<!-- $Id: Language.htm $ -->
<!-- Originally: language.txt -->
</head>
<body>
<!-- [1.0 begin visible header] -------------------------------------------- -->
<!-- [1.1 begin headline] -------------------------------------------------- -->
<p><table width="100%" border="0">
<tr><th align="center" bgcolor="#CCCC00"><font size=6>
The relationship between Ghostscript and PostScript
</font>
</table>
<!-- [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 Level 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="#Graphics_state">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="#String">String operators</a>
<li><a href="#Relational">Relational operators</a>
<li><a href="#File">File operators</a>
<li><a href="#Filters">Filters</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="#Device_parameters">Device parameters</a>
<li><a href="#Miscellaneous_additions">Miscellaneous additions</a>
</ul></blockquote>
<!-- [1.2 end table of contents] ------------------------------------------- -->
<!-- [1.3 begin hint] ------------------------------------------------------ -->
<p>For other information, see the <a href="Readme.htm">Ghostscript
overview</a>.
<!-- [1.3 end hint] -------------------------------------------------------- -->
<hr>
<!-- [1.0 end visible header] ---------------------------------------------- -->
<!-- [2.0 begin contents] -------------------------------------------------- -->
<h1><a name="Capabilities"></a>Ghostscript's capabilities in relation to PostScript</h1>
<p>
The Ghostscript interpreter, except as noted below, is intended to execute
properly any source program written in the (Level 2) <b>PostScript</b>
language as defined in the December 1990 printing of the
<a href="http://cseng.awl.com/bookdetail.qry?ISBN=0-201-18127-4&ptype=0"><em>PostScript
Language Reference Manual</em> (Second Edition, ISBN 0-201-18127-4)</a>
published by Addison-Wesley. 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 <em>PostScript
Language Reference Manual</em>, 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
"<b><tt>status</tt></b>" operator. The base interpreter may be configured
(see the <a href="Make.htm">documentation on building Ghostscript</a> for
how to configure it) by adding any combination of the following:
<ul>
<li>The ability to process PostScript Type 1 fonts. This facility is
normally 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 available
only 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 Second
Edition, but excluding the operators listed in section A.1.2. These
facilities 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 Second
Edition, and the ability to handle Type 0 fonts. These facilities are
available 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. These
facilities are available only if the <b><tt>filter</tt></b>,
<b><tt>dps</tt></b>, or <b><tt>level2</tt></b> feature was selected when
Ghostscript was built.
<li>The PostScript Level 2 <b><tt>DCTEncode</tt></b> and
<b><tt>DCTDecode</tt></b> filters. These facilities are available only if
the <b><tt>dct</tt></b> or <b><tt>level2</tt></b> feature was selected when
Ghostscript was built.
<li>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
<b><tt>level2</tt></b> feature was selected when Ghostscript was built.
<li>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 <b><tt>epsf</tt></b> feature was selected when
Ghostscript was built.
</ul>
<p>
Adding all of these produces a full Level 2 PostScript language
interpreter.
<p><a name="PDF1.2"></a>
Ghostscript can also interpret files in the Portable Document Format (PDF)
1.2 format defined in the
<a href="http://www.adobe.com/supportservice/devrelations/PDFS/TN/PDFSPEC.PDF"><em>Portable
Document Format Reference Manual</em> Version 1.2</a> of November 12, 1996,
distributed by <a href="http://www.adobe.com/">Adobe Systems
Incorporated</a>. This facility is available only if the
"<b><tt>pdf</tt></b>" feature was selected when Ghostscript was built.
<p>
Ghostscript also includes a number of
<a href="#Additional_operators">additional operators</a> defined below that
are not in the PostScript language defined by Adobe.
<hr>
<h1><a name="Implementation_limits"></a>Implementation limits</h1>
<p>
The implementation limits show here correspond to those in Tables B.1 and
B.2 of the Second Edition. Asterisks (*) mark the ones different from the
limits in the Second Edition.
<h2><a name="Architectural_limits"></a>Architectural limits</h2>
<blockquote><table cellpadding=0 cellspacing=0>
<tr valign=top> <td>integer
<td>
<td>
<td>32-bit twos complement integer
<tr valign=top> <td>real
<td>
<td>
<td>single-precision IEEE float
<tr valign=top> <td>array
<td>
<td>*
<td>8191 elements (16-bit systems)
<tr valign=top> <td>
<td>
<td>
<td>65535 elements (32-bit systems)
<tr valign=top> <td>dictionary
<td>
<td>*
<td>8190 elements (16-bit systems)
<tr valign=top> <td>
<td>
<td>
<td>65534 elements (32-bit systems)
<tr valign=top> <td>string
<td>
<td>*
<td>65535 characters
<tr valign=top> <td>name
<td>
<td>*
<td>16383 characters
<tr valign=top> <td>filename
<td>
<td>
<td>100 characters
<tr valign=top> <td>save level
<td>
<td>*
<td>none (capacity of memory)
<tr valign=top> <td>gsave level
<td>
<td>*
<td>none (capacity of memory)
</table></blockquote>
<h2><a name="Typical_memory_limits"></a>Typical memory limits in Level 1</h2>
<blockquote><table cellpadding=0 cellspacing=0>
<tr valign=top> <td><b><tt>userdict</tt></b>
<td>
<td>
<td>200
<tr valign=top> <td><b><tt>FontDirectory</tt></b>
<td>
<td>
<td>100
<tr valign=top> <td>operand stack
<td>
<td>*
<td>800
<tr valign=top> <td>dictionary stack
<td>
<td>
<td>20
<tr valign=top> <td>execution stack
<td>
<td>
<td>250
<tr valign=top> <td>interpreter level
<td>
<td>*
<td>none (capacity of memory)
<tr valign=top> <td>path
<td>
<td>*
<td>none (capacity of memory)
<tr valign=top> <td>dash
<td>
<td>
<td>11
<tr valign=top> <td>VM
<td>
<td>*
<td>capacity of memory
<tr valign=top> <td>file
<td>
<td>*
<td>determined by operating system
<tr valign=top> <td>image
<td>
<td>*
<td>65535 values (samples × components) for 1-, 2-, 4-, or 8-bit samples
<tr valign=top> <td>
<td>
<td>
<td>32767 values for 12-bit samples
</table></blockquote>
<h2><a name="VM_consumption"></a>Other differences in VM consumption</h2>
<p>
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.
<hr>
<h1><a name="Additional_operators"></a>Additional operators in Ghostscript</h1>
<h2><a name="Graphics_and_text"></a>Graphics and text operators</h2>
<h3><a name="Graphics_state"></a>Graphics state operators</h3>
<dl>
<dt><b><tt><bool> .setaccuratecurves -</tt></b>
<dd>Sets a graphics state flag that determines whether curves and arcs,
when flattened, always start and end with a line that is a segment of the
tangent; this also causes butt and square caps to be properly perpendicular
to the tangent. <b><tt>initgraphics</tt></b> sets this flag to false, to
match other PostScript implementations.
</dl>
<dl>
<dt><b><tt>- .currentaccuratecurves <bool></tt></b>
<dd>Returns the current value of the accurate curves flag.
</dl>
<dl>
<dt><b><tt><bool> .setclipoutside -</tt></b>
<dd>Sets a graphics state flag that determines whether the effective
clipping region is the inside (false) or the outside (true) of the region
defined by the clipping operators (<b><tt>clip</tt></b>,
<b><tt>rectclip</tt></b>, etc.) <b><tt>initclip</tt></b> sets this flag to
false.
</dl>
<dl>
<dt><b><tt>- .currentclipoutside <bool></tt></b>
<dd>Returns the current value of the outside clipping flag.
</dl>
<dl>
<dt><b><tt><bool> .setdashadapt -</tt></b>
<dd>Sets a graphics state flag that determines whether dash patterns do
(true) or do not (false) automatically scale themselves so that each line
segment consists of an integral number of pattern repetitions.
<b><tt>initgraphics</tt></b> sets this flag to false.
</dl>
<dl>
<dt><b><tt>- .currentdashadapt <bool></tt></b>
<dd>Returns the current value of the dash adaptation flag.
</dl>
<dl>
<dt><b><tt><matrix> .setdefaultmatrix -</tt></b>
<dd>Sets the default matrix that is returned by
<b><tt>defaultmatrix</tt></b> and installed by <b><tt>initmatrix</tt></b>.
Ordinary programs should not use this operator.
</dl>
<dl>
<dt><b><tt><num> <bool> .setdotlength -</tt></b>
<dd>Sets a graphics state parameter that determines the handling of
zero-length lines (dots). If the dot length is zero, dots are painted as
circles if round line caps are in effect, otherwise they are not painted at
all. If the dot length is non-zero, dots are treated exactly like lines of
the given length: the length is specified in user coordinates (like line
width) if <b><tt>bool</tt></b> is false, or in default user coordinates of
points (units of 1/72in; see the <a href="Devices.htm#Measurements">notes
on measurements</a> in the documentation on devices) if
<b><tt>bool</tt></b> is true. Dots occurring as part of dash patterns will
be oriented correctly; isolated dots will be oriented as though they were
part of a vertical line. <b><tt>initgraphics</tt></b> sets the dot length
to zero.
</dl>
<dl>
<dt><b><tt>- .currentdotlength <num> <bool></tt></b>
<dd>Returns the current dot length and dot length mode.
</dl>
<dl>
<dt><b><tt><dx> <dy> .setfilladjust2 -</tt></b>
<dd>Sets graphics state parameters that cause all filled and stroked
regions to be "fattened" by the given amount relative to an algorithm that
only paints pixels whose centers fall within the region to be painted.
<b><tt>dx</tt></b> and <b><tt>dy</tt></b> are numbers between 0 and 0.5,
measured in device space. The only two values that are likely to be useful
are 0, which gives a pure center-of-pixel rule, and 0.5, which gives
Adobe's any-part-of-pixel rule. (0.5 is treated slightly specially in
order to create half-open pixels per Adobe's specification.)
</dl>
<dl>
<dt><b><tt>- .currentfilladjust2 <dx> <dy></tt></b>
<dd>Returns the current fill adjustment values.
</dl>
<h3><a name="Path"></a>Path operators</h3>
<dl>
<dt><b><tt>- .dashpath -</tt></b>
<dd>If there is no current dash pattern, does nothing. Otherwise, does the
equivalent of <b><tt>flattenpath</tt></b> and then chops up the path as
determined by the dash pattern.
</dl>
<dl>
<dt><b><tt><x> <y> <width> <height> .rectappend -</tt></b>
<dt><b><tt><numarray> .rectappend -</tt></b>
<dt><b><tt><numstring> .rectappend -</tt></b>
<dd>Appends a rectangle or rectangles to the current path, in the same
manner as <b><tt>rectfill</tt></b>, <b><tt>rectclip</tt></b>, etc. Defined
only if the <b><tt>dps</tt></b> or <b><tt>level2</tt></b> option was
selected when Ghostscript was built.
</dl>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -