⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 language.htm

📁 GhostScript的源代码
💻 HTM
📖 第 1 页 / 共 3 页
字号:

<h3><a name="Painting"></a>Painting operators</h3>

<p>
Ghostscript supports an experimental extension of the PostScript imaging
model to include <b><tt>RasterOp</tt></b> and some related facilities.
This extension is available only if the <b><tt>rasterop</tt></b> option was
selected when building Ghostscript.

<p>
With the <b><tt>RasterOp</tt></b> extension, imaging operations compute a
function <b>D&nbsp;=&nbsp;f(D,S,T)</b> in RGB space, where <b>f</b> is an
arbitrary 3-input Boolean function, <b>D</b> is the destination (frame
buffer or print buffer), <b>S</b> is the source (described below), and
<b>T</b> is the texture (the current PostScript color, which may be a
pattern).  The source and texture depend on the PostScript imaging
operation:

<ul>
<li>For <b><tt>fill</tt></b> and <b><tt>stroke</tt></b>, the source is
solid black, covering the region to be painted; the texture is the current
PostScript color.

<li>For <b><tt>show</tt></b> and <b><tt>imagemask</tt></b>, the source is
solid black, covering the pixels to be painted; the texture is the current
PostScript color.

<li>For <b><tt>image</tt></b> and <b><tt>colorimage</tt></b>, the source is
the image data; the texture depends on an optional Boolean parameter,
<b><tt>CombineWithColor</tt></b>, in the image dictionary.  If
<b><tt>CombineWithColor</tt></b> is false (the default), the texture is
solid black.  If <b><tt>CombineWithColor</tt></b> is true, the texture is
the current color.  For the non-dictionary form of the image operator,
<b><tt>CombineWithColor</tt></b> is considered to be false.
</ul>

<p>
The <b><tt>rasterop</tt></b> option adds the following operators:

<dl>
<dt><b><tt>&lt;int8&gt; .setrasterop -</tt></b>
<dd>Sets the <b><tt>RasterOp</tt></b> function in the graphics state.  The
default function is 252, Source | Texture.
</dl>

<dl>
<dt><b><tt>- .currentrasterop &lt;int8&gt;</tt></b>
<dd>Returns the current <b><tt>RasterOp</tt></b> function.
</dl>

<dl>
<dt><b><tt>&lt;bool&gt; .setsourcetransparent -</tt></b>
<dd>Sets source transparency in the graphics state.  When source
transparency is true, white source pixels prevent storing into the
destination, regardless of what the <b><tt>RasterOp</tt></b> function
returns.  The default source transparency is false.
</dl>

<dl>
<dt><b><tt>- .currentsourcetransparent &lt;bool&gt; -</tt></b>
<dd>Returns the current source transparency.
</dl>

<dl>
<dt><b><tt>&lt;bool&gt; .settexturetransparent -</tt></b>
<dd>Sets texture transparency in the graphics state.  When texture
transparency is true, white texture pixels prevent storing into the
destination, regardless of what the <b><tt>RasterOp</tt></b> function
returns.  The default texture transparency is false.
</dl>

<dl>
<dt><b><tt>- .currenttexturetransparent &lt;bool&gt; -</tt></b>
<dd>Returns the current texture transparency.
</dl>

<p>
For more information on RasterOp and transparency, please consult chapter 5
of the "PCL 5 Color Technical Reference Manual",
<a href="http://www.hp.com/cposupport/printers/support_doc/bpl01354.html">Hewlett-Packard
Manual Part No. 5961-0635</a>.

<h3><a name="Character"></a>Character operators</h3>

<dl>
<dt><b><tt>&lt;string&gt; &lt;bool&gt; .charboxpath -</tt></b>
<dd>For each character <b>C</b> in the rendering of &lt;string&gt;, let the
bounding box of <b>C</b> <b><em>in device space</em></b> be the four
<b><em>user-space</em></b> points p1x/y, p2x/y, p3x/y, and p4x/y.  For each
character in order, <b><tt>.charboxpath</tt></b> appends the following to
the current path:

<p><ul><li>If <b><tt>&lt;bool&gt;</tt></b> is true, the equivalent of:

<blockquote>
p1x p1y <b><tt>moveto</tt></b><br>
p2x p2y <b><tt>lineto</tt></b><br>
p3x p3y <b><tt>lineto</tt></b><br>
p4x p4y <b><tt>lineto</tt></b><br>
<b><tt>closepath</tt></b>
</blockquote>
</ul>

<p>
This creates a path whose <b><tt>pathbbox</tt></b> is the
<b><tt>bbox</tt></b> of the string.

<p><ul><li>If <b><tt>&lt;bool&gt;</tt></b> is false, the equivalent of:

<blockquote>
p1x p1y <b><tt>moveto</tt></b><br>
p3x p3y <b><tt>lineto</tt></b>
</blockquote>
</ul>

<p>
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 <b><tt>pathbbox</tt></b> is the <b><tt>bbox</tt></b> of the string.
</dl>

<dl>
<dt><b><tt>&lt;font&gt; &lt;charname|charcode&gt; &lt;charname&gt; &lt;charstring&gt; .type1execchar -</tt></b>
<dd>Does all the work for rendering a Type 1 outline.  This operator, like
<b><tt>setcharwidth</tt></b> and <b><tt>setcachedevice</tt></b>, is valid
only in the context of a show operator -- that is, it must only be called
from within a <b><tt>BuildChar</tt></b> or <b><tt>BuildGlyph</tt></b>
procedure.
</dl>

<dl>
<dt><b><tt>&lt;font&gt; &lt;charcode&gt; %Type1BuildChar -</tt></b>
<dd>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 ...<b><tt>show</tt></b>, <b><tt>stringwidth</tt></b>, or
<b><tt>charpath</tt></b>), it looks up the name <b><tt>BuildChar</tt></b>
in the font dictionary to find a procedure to run.  If it does not find
this name, and if the <b><tt>FontType</tt></b> is 1, the interpreter
instead uses the value (looked up on the dictionary stack in the usual way)
of the name <b><tt>%Type1BuildChar</tt></b>.

<p>
The standard definition of <b><tt>%Type1BuildChar</tt></b> is in the
initialization file <b><tt>gs_type1.ps</tt></b>.  Users should not need to
redefine <b><tt>%Type1BuildChar</tt></b>, except perhaps for tracing or
debugging.
</dl>

<dl>
<dt><b><tt>&lt;font&gt; &lt;charname&gt; %Type1BuildGlyph -</tt></b>
<dd>Provides the Type 1 implementation of <b><tt>BuildGlyph</tt></b>.
</dl>

<h2><a name="Other"></a>Other operators</h2>

<h3><a name="Mathematical"></a>Mathematical operators</h3>

<dl>
<dt><b><tt>&lt;number&gt; arccos &lt;number&gt;</tt></b>
<dd>Computes the arc cosine of a number between -1 and 1.
</dl>

<dl>
<dt><b><tt>&lt;number&gt; arcsin &lt;number&gt;</tt></b>
<dd>Computes the arc sine of a number between -1 and 1.
</dl>

<h3><a name="String"></a>String operators</h3>

<dl>
<dt><b><tt>&lt;state&gt; &lt;fromString&gt; &lt;toString&gt; .type1encrypt &lt;newState&gt; &lt;toSubstring&gt;</tt></b>
<dd>Encrypts <b><tt>fromString</tt></b> according to the algorithm for
Adobe Type 1 fonts, writing the result into <b><tt>toString</tt></b>.
<b><tt>toString</tt></b> must be at least as long as
<b><tt>fromString</tt></b>, or a rangecheck error occurs.
<b><tt>state</tt></b> is the initial state of the encryption algorithm (a
16-bit non-negative integer); <b><tt>newState</tt></b> is the new state of
the algorithm.
</dl>

<dl>
<dt><b><tt>&lt;state&gt; &lt;fromString&gt; &lt;toString&gt; .type1decrypt &lt;newState&gt; &lt;toSubstring&gt;</tt></b>
<dd>Decrypts <b><tt>fromString</tt></b> according to the algorithm for
Adobe Type 1 fonts, writing the result into <b><tt>toString</tt></b>.
Other specifications are as for <b><tt>type1encrypt</tt></b>.
</dl>

<h3><a name="Relational"></a>Relational operators</h3>

<dl>
<dt><b><tt>&lt;number|string&gt; &lt;number|string&gt; max &lt;number|string&gt;</tt></b>
<dd>Returns the larger of two numbers or strings.
</dl>

<dl>
<dt><b><tt>&lt;number|string&gt; &lt;number|string&gt; min &lt;number|string&gt;</tt></b>
<dd>Returns the smaller of two numbers or strings.
</dl>

<h3><a name="File"></a>File operators</h3>

<dl>
<dt><b><tt>&lt;string&gt; findlibfile &lt;foundstring&gt; &lt;file&gt; true</tt></b>
<dt><b><tt>&lt;string&gt; findlibfile &lt;string&gt; false</tt></b>
<dd>Opens the file of the given name for reading, searching through
directories <a href="Use.htm#Finding_files">as described in the usage
documentation</a>.  If the search fails, <b><tt>findlibfile</tt></b> simply
pushes false on the stack and returns, rather than causing an error.
</dl>

<dl>
<dt><b><tt>&lt;file&gt; &lt;integer&gt; unread -</tt></b>
<dd>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 <b><tt>ioerror</tt></b>
error.  May also cause an <b><tt>ioerror</tt></b> if the last operation on
the file was not a reading operation.
</dl>

<dl>
<dt><b><tt>&lt;file&gt; &lt;device&gt; writeppmfile -</tt></b>
<dd>Writes the contents of the device, which must be an image device, onto
the file, in Portable PixMap (ppm) format.  Does not close the file.
</dl>

<p>
Ghostscript also supports the following <b><tt>IODevice</tt></b> in
addition to a subset of those defined in the Adobe documentation:
<b><tt>%pipe%command</tt></b>, which opens a pipe on the given command.
This is supported only on operating systems that provide
<b><tt>popen</tt></b> (primarily Unix systems, and not all of those).

<h3><a name="Filters"></a>Filters</h3>

<p>
Ghostscript supports all the standard PostScript Level 2 filters, except
that it does not currently support the <b><tt>EarlyChange</tt></b> key in
the <b><tt>LZWEncode</tt></b> filter.  Ghostscript also supports the as yet
undocumented <b><tt>FlateEncode</tt></b> and <b><tt>FlateDecode</tt></b>
filters from <a href="#PDF1.2">PDF 1.2</a> and (presumably) PostScript
Level 3, except for the <b><tt>Effort</tt></b> key in
<b><tt>FlateEncode</tt></b>.  In addition, Ghostscript supports the
following non-standard filters:

<dl>
<dt><b><tt>&lt;target&gt; /BCPEncode filter &lt;file&gt;</tt></b>
<dt><b><tt>&lt;source&gt; /BCPDecode filter &lt;file&gt;</tt></b>
<dd>Create filters that implement the Adobe Binary Communications Protocol.
See Adobe documentation for details.
</dl>

<dl>
<dt><b><tt>&lt;target&gt; &lt;seed_integer&gt; /eexecEncode filter &lt;file&gt;</tt></b>
<dd>Creates a filter for encrypting data into the <b><tt>eexec</tt></b>
encrypted format described in the Adobe Type 1 Font Format documentation.
The <b><tt>seed_integer</tt></b> must be 55665 for proper operation.  This
filter produces binary output and does not include the initial 4 (or lenIV)
garbage bytes.
</dl>

<dl>
<dt><b><tt>&lt;source&gt; &lt;seed_integer&gt; /eexecDecode filter &lt;file&gt;</tt></b>
<dt><b><tt>&lt;source&gt; &lt;dict&gt; /eexecDecode filter &lt;file&gt;</tt></b>
<dd>Creates a filter for decrypting data encrypted using
<b><tt>eexec</tt></b> encryption as described in the Adobe Type 1 Font
Format documentation.  The <b><tt>seed_integer</tt></b> must be 55665 for
proper operation.  Recognized dictionary keys are:

<blockquote>
<b><tt>seed &lt;16-bit integer&gt;</tt></b> (required)<br>
<b><tt>lenIV &lt;non-negative integer&gt;</tt></b> (default=4)
</blockquote>
</dl>

<dl>
<dt><b><tt>&lt;source&gt; /PCXDecode filter &lt;file&gt;</tt></b>
<dd>Creates a filter that decodes data in the run-length encoding used in
the PCX graphics file format.
</dl>

<dl>
<dt><b><tt>&lt;source&gt; &lt;hex_boolean&gt; /PFBDecode filter &lt;file&gt;</tt></b>
<dd>Creates a filter that decodes data in <b><tt>.PFB</tt></b> format, the
usual semi-binary representation for Type 1 font files on IBM PC and
compatible systems.  If <b><tt>hex_boolean</tt></b> is true, binary packets
are converted to hex; if false, binary packets are not converted.
</dl>

<dl>
<dt><b><tt>&lt;target&gt; &lt;dict&gt; /PixelDifferenceEncode filter &lt;file&gt;</tt></b>
<dt><b><tt>&lt;source&gt; &lt;dict&gt; /PixelDifferenceDecode filter &lt;file&gt;</tt></b>
<dd>Implements the Predictor=2 pixel-differencing option of the LZW
filters.  Recognized keys are:

<blockquote>
<b><tt>Colors &lt;integer&gt;</tt></b> (1 to 4, default=1)<br>
<b><tt>BitsPerComponent &lt;integer&gt;</tt></b> (1, 2, 4, or 8, default=8)<br>
<b><tt>Columns &lt;integer&gt;</tt></b> (&gt;= 0, required)
</blockquote>

<p>
See the Adobe <a href="#PDF1.2"><em>Portable Document Format Reference
Manual</em></a> for details.
</dl>

<dl>
<dt><b><tt>&lt;target&gt; &lt;dict&gt; /PNGPredictorEncode filter &lt;file&gt;</tt></b>
<dt><b><tt>&lt;source&gt; &lt;dict&gt; /PNGPredictorDecode filter &lt;file&gt;</tt></b>
<dd>Implements the "filter" algorithms of the
<a href="http://www.cdrom.com/pub/png/">Portable Network Graphics (PNG)
graphics format</a>.  Recognized keys are:

<blockquote><table cellpadding=0 cellspacing=0>
<tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">Keys recognized in PNG filter algorithms</font><hr>
<tr valign=bottom>
	<th align=left>Key
	<td>&nbsp;&nbsp;
	<th align=left>Range
	<td>&nbsp;&nbsp;
	<th align=left>Default
<tr>	<td colspan=5><hr>
<tr valign=top>	<td><b><tt>Colors &lt;integer&gt;</tt></b>
	<td>&nbsp;&nbsp;&nbsp;
	<td>1 to 16
	<td>&nbsp;&nbsp;
	<td>16
<tr valign=top>	<td><b><tt>BitsPerComponent &lt;integer&gt;</tt></b>
	<td>&nbsp;
	<td>1, 2, 4, 8, or 16
	<td>&nbsp;&nbsp;
	<td>8
<tr valign=top>	<td><b><tt>Columns &lt;integer&gt;</tt></b>
	<td>&nbsp;
	<td>&gt;= 0
	<td>&nbsp;&nbsp;
	<td>1
<tr valign=top>	<td><b><tt>Predictor &lt;integer&gt;</tt></b>
	<td>&nbsp;
	<td>10 to 15
	<td>&nbsp;&nbsp;
	<td>15
</table></blockquote>

<p>
The <b><tt>Predictor</tt></b> is the PNG algorithm number + 10 for the
<b><tt>Encoding</tt></b> filter; the <b><tt>Decoding</tt></b> filter
ignores <b><tt>Predictor</tt></b>.  15 means the encoder attempts to
optimize the choice of algorithm.  For more details see the PNG
specification

<blockquote>
<a href="http://www.w3.org/TR/REC-png">http://www.w3.org/TR/REC-png</a>
</blockquote>
</dl>

<dl>
<dt><b><tt>&lt;target&gt; /TBCPEncode filter &lt;file&gt;</tt></b>
<dt><b><tt>&lt;source&gt; /TBCPDecode filter &lt;file&gt;</tt></b>
<dd>Create filters that implement the Adobe Tagged Binary Communications
Protocol.  See Adobe documentation for details.
</dl>

<dl>
<dt><b><tt>&lt;target&gt; /zlibEncode filter &lt;file&gt;</tt></b>
<dt><b><tt>&lt;source&gt; /zlibDecode filter &lt;file&gt;</tt></b>
<dd>Creates filters that use the zlib data compression method (the same
method used by the <b><tt>gzip</tt></b> application).  This filter is
available only if the <b><tt>fzlib</tt></b> feature was selected when
Ghostscript was built.
</dl>

<p>
Some versions of Ghostscript may also support other non-standard filters
for experimental purposes.  The current version includes the following
non-standard filters, which are not documented further.  No guarantee is
made that these filters will exist in compatible form, or at all, in future
versions.

<blockquote><b><tt>
<b><tt>&lt;target/source&gt; &lt;string&gt; ByteTranslateEncode/Decode</tt></b>
<b><tt>&lt;target&gt; &lt;int&gt; BigStringEncode</tt></b>
<b><tt>&lt;target/source&gt; &lt;dict&gt; BoundedHuffmanEncode/Decode</tt></b>
<blockquote>
<b><tt>FirstBitLowOrder &lt;bool&gt; false</tt></b>
<b><tt>MaxCodeLength &lt;int&gt; 16</tt></b>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -