?? lib.htm
字號(hào):
<html>
<head>
<title>The Ghostscript library</title>
<!-- $Id: Lib.htm $ -->
<!-- Originally: lib.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 Ghostscript library
</font>
</table>
<!-- [1.1 end headline] ---------------------------------------------------- -->
<!-- [1.2 begin table of contents] ----------------------------------------- -->
<h2>Table of contents</h2>
<blockquote><ul>
<li><a href="#GS_library">The Ghostscript library</a>
<li><a href="#PS_operator_API">PostScript operator API</a>
<ul>
<li><a href="#Patterns">Patterns</a>
<li><a href="#Lower_level_API">Lower-level API</a>
</ul>
<li><a href="#Full_example">A full example</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="GS_library"></a>The Ghostscript library</h1>
<p>
This document describes the Ghostscript library, a set of procedures
to implement the graphics and filtering capabilities that are primitive
operations in the PostScript language and in Adobe Portable Document Format
(PDF).
<p>
Ghostscript is actually two programs: a language interpreter, and a
graphics library. The library provides, in the form of C procedures, all
the graphics functions of the language, that is, approximately those
facilities listed in section 8.1 of the
<em><a href="http://cseng.awl.com/bookdetail.qry?ISBN=0-201-18127-4&ptype=0">PostScript
Language Reference Manual</a></em>, Second Edition, starting with the
graphics state operators. In addition, the library provides some
lower-level graphics facilities that offer higher performance in exchange
for less generality.
<hr>
<h1><a name="PS_operator_API"></a>PostScript operator API</h1>
<p>
The highest level of the library, which is the one that most clients will
use, directly implements the PostScript graphics operators with procedures
named <b><tt>gs_XXX</tt></b>, for instance <b><tt>gs_moveto</tt></b> and
<b><tt>gs_fill</tt></b>. Nearly all of these procedures take graphics
state objects as their first arguments, such as
<blockquote><b><tt>
int gs_moveto(gs_state *, double, double);
</tt></b></blockquote>
<p>
Nearly every procedure returns an integer code which is >= 0 for a
successful return or <0 for a failure. The failure codes correspond
directly to PostScript errors, and are defined in
<b><tt>gserrors.h</tt></b>.
<p>
The library implements all the operators in the following sections of the
<em><a href="http://cseng.awl.com/bookdetail.qry?ISBN=0-201-18127-4&ptype=0">PostScript
Language Reference Manual</a></em>, Second Edition, with the indicated
omissions and with the APIs defined in the indicated <b><tt>.h</tt></b>
files. A header of the form <b><em>A.h(B.h)</em></b> indicates that
<b><em>A.h</em></b> is included in <b><em>B.h</em></b>, so
<b><em>A.h</em></b> need not be included explicitly if <b><em>B.h</em></b>
is included. Operators marked with * in the "omissions" column are not
implemented directly; the library provides lower-level procedures that can
be used to implement the operator.
<p>
There are slight differences in the operators that return multiple values,
since C's provisions for this are awkward. Also, the control structure for
the operators involving callback procedures (<b><tt>pathforall</tt></b>,
<b><tt>image</tt></b>, <b><tt>colorimage</tt></b>,
<b><tt>imagemask</tt></b>) is partly inverted: the client calls a procedure
to set up an enumerator object, and then calls another procedure for each
iteration. The <b><tt>...show</tt></b> operators,
<b><tt>charpath</tt></b>, and <b><tt>stringwidth</tt></b> also use an
inverted control structure.
<blockquote><table cellpadding=0 cellspacing=0>
<tr valign=bottom>
<th align=left>Section<br>(operators)
<td>
<th align=left>Headers
<td>
<th align=left>Omissions
<tr> <td colspan=5><hr>
<tr valign=top> <td>Graphics state -- device-independent
<td>
<td><b><tt>gscolor.h</tt></b>(<b><tt>gsstate.h</tt></b>)<br><b><tt>gscolor1.h</tt></b><br><b><tt>gscolor2.h</tt></b><br><b><tt>gscspace.h</tt></b><br><b><tt>gshsb.h</tt></b><br><b><tt>gsline.h</tt></b>(<b><tt>gsstate.h</tt></b>)<br><b><tt>gsstate.h</tt></b>
<td>
<td>
<tr> <td>
<tr valign=top> <td>Graphics state -- device-dependent
<td>
<td><b><tt>gscolor.h</tt></b>(<b><tt>gsstate.h</tt></b>)<br><b><tt>gscolor1.h</tt></b><br><b><tt>gscolor2.h</tt></b><br><b><tt>gsht.h</tt></b>(<b><tt>gsht1.h</tt></b>,<b><tt>gsstate.h</tt></b>)<br><b><tt>gsht1.h</tt></b><br><b><tt>gsline.h</tt></b>(<b><tt>gsstate.h</tt></b>)
<td>
<td>
<tr> <td>
<tr valign=top> <td>Coordinate system and matrix
<td>
<td><b><tt>gscoord.h</tt></b><br><b><tt>gsmatrix.h</tt></b>
<td>
<td><b><tt>*matrix</tt></b>, <b><tt>*identmatrix</tt></b>, <b><tt>*concatmatrix</tt></b>, <b><tt>*invertmatrix</tt></b>
<tr> <td>
<tr valign=top> <td>Path construction
<td>
<td><b><tt>gspath.h</tt></b><br><b><tt>gspath2.h</tt></b>
<td>
<td><b><tt>*arct</tt></b>, <b><tt>*pathforall</tt></b>, <b><tt>ustrokepath</tt></b>, <b><tt>uappend</tt></b>, <b><tt>upath</tt></b>, <b><tt>ucache</tt></b>
<tr> <td>
<tr valign=top> <td>Painting
<td>
<td><b><tt>gsimage.h</tt></b><br><b><tt>gspaint.h</tt></b><br><b><tt>gspath2.h</tt></b>
<td>
<td><b><tt>*image</tt></b>, <b><tt>*colorimage</tt></b>, <b><tt>*imagemask</tt></b>, <b><tt>ufill</tt></b>, <b><tt>ueofill</tt></b>, <b><tt>ustroke</tt></b>
<tr> <td>
<tr valign=top> <td>Form and pattern
<td>
<td><b><tt>gscolor2.h</tt></b>
<td>
<td><b><tt>execform</tt></b>
<tr> <td>
<tr valign=top> <td>Device setup and output
<td>
<td><b><tt>gsdevice.h</tt></b>
<td>
<td><b><tt>*showpage</tt></b>, <b><tt>*set</tt></b>/<b><tt>currentpagedevice</tt></b>
<tr> <td>
<tr valign=top> <td>Character and font
<td>
<td><b><tt>gschar.h</tt></b><br><b><tt>gsfont.h</tt></b>
<td>
<td>*(all the <b><tt>show</tt></b> operators), <b><tt>definefont</tt></b>, <b><tt>undefinefont</tt></b>, <b><tt>findfont</tt></b>, <b><tt>*scalefont</tt></b>, <b><tt>*makefont</tt></b>, <b><tt>selectfont</tt></b>, <b><tt>[Global]FontDirectory</tt></b>, <b><tt>Standard</tt></b>/<b><tt>ISOLatin1Encoding</tt></b>, <b><tt>findencoding</tt></b>
</table></blockquote>
<p>
The following procedures from the list above operate differently from their
PostScript operator counterparts, as explained here:
<dl>
<dt><b><tt>gs_makepattern(gscolor2.h)</tt></b>
<dd>Takes an explicit current color, rather than using the current color in
the graphics state. Takes an explicit allocator for allocating the pattern
implementation. See below for more details on
<b><tt>gs_makepattern</tt></b>.
</dl>
<dl>
<dt><b><tt>gs_setpattern(gscolor2.h)</tt></b>
<dt><b><tt>gs_setcolor(gscolor2.h)</tt></b>
<dt><b><tt>gs_currentcolor(gscolor2.h)</tt></b>
<dd>Use <b><tt>gs_client_color</tt></b> rather than a set of color
parameter values. See below for more details on
<b><tt>gs_setpattern</tt></b>.
</dl>
<dl>
<dt><b><tt>gs_currentdash_length/pattern/offset(gsline.h)</tt></b>
<dd>Splits up <b><tt>currentdash</tt></b> into three separate procedures.
</dl>
<dl>
<dt><b><tt>gs_screen_init/currentpoint/next/install(gsht.h)</tt></b>
<dd>Provide an "enumeration style" interface to <b><tt>setscreen</tt></b>.
(<b><tt>gs_setscreen</tt></b> is also implemented.)
</dl>
<dl>
<dt><b><tt>gs_rotate/scale/translate(gscoord.h)</tt></b>
<dt><b><tt>gs_[i][d]transform(gscoord.h)</tt></b>
<dd>These always operate on the graphics state CTM. The corresponding
operations on free-standing matrices are in <b><tt>gsmatrix.h</tt></b> and
have different names.
</dl>
<dl>
<dt><b><tt>gs_path_enum_alloc/init/next/cleanup(gspath.h)</tt></b>
<dd>Provide an "enumeration style" implementation of
<b><tt>pathforall</tt></b>.
</dl>
<dl>
<dt><b><tt>gs_image_enum_alloc(gsimage.h)</tt></b>
<dt><b><tt>gs_image_init/next/cleanup(gsimage.h)</tt></b>
<dd>Provide an "enumeration style" interface to the equivalent of
<b><tt>image</tt></b>, <b><tt>imagemask</tt></b>, and
<b><tt>colorimage</tt></b>. In the <b><tt>gs_image_t</tt></b>,
<b><tt>ColorSpace</tt></b> provides an explicit color space, rather than
using the current color space in the graphics state;
<b><tt>ImageMask</tt></b> distinguishes <b><tt>imagemask</tt></b> from
<b><tt>[color]image</tt></b>.
</dl>
<dl>
<dt><b><tt>gs_get/putdeviceparams(gsdevice.h)</tt></b>
<dd>Take a <b><tt>gs_param_list</tt></b> for specifying or receiving the
parameter values. See <b><tt>gsparam.h</tt></b> for more details.
</dl>
<dl>
<dt><b><tt>gs_show_enum_alloc/release(gschar.h)</tt></b>
<dt><b><tt>gs_xxxshow_[n_]init(gschar.h)</tt></b>
<dt><b><tt>gs_show_next(gschar.h)</tt></b>
<dd>Provide an "enumeration style" interface to writing text. Note that
control returns to the caller if the character must be rasterized.
</dl>
<p>
This level of the library also implements the following operators from other
sections of the Manual:
<blockquote><table cellpadding=0 cellspacing=0>
<tr valign=bottom>
<th align=left>Section<br>(operators)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -