ref: 403fef45c1a65aa74c449764e2857597fc03290a
dir: /sys/src/cmd/gs/doc/Xfonts.htm/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Ghostscript's external font and text interface</title> <!-- $Id: Xfonts.htm,v 1.39 2005/10/20 19:46:23 ray Exp $ --> <!-- Originally: xfonts.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's external font and text interface</h1> <!-- [1.1 end headline] ==================================================== --> <!-- [1.2 begin table of contents] ========================================= --> <h2>Table of contents</h2> <blockquote><ul> <li><a href="#Introduction">Introduction</a> <li><a href="#Types">Types</a> <li><a href="#Implementation_procedures">Implementation procedures</a> <li><a href="#Font_level_procedures">Font-level procedures</a> <ul> <li><a href="#lookup_font"><b><tt>lookup_font</tt></b></a> <li><a href="#char_xglyph"><b><tt>char_xglyph</tt></b></a> <li><a href="#char_metrics"><b><tt>char_metrics</tt></b></a> <li><a href="#render_char"><b><tt>render_char</tt></b></a> <li><a href="#release"><b><tt>release</tt></b></a> </ul> </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] ================================================== --> <h2><a name="Introduction"></a>Introduction</h2> <p> Ghostscript can use the character rasterizer provided by the underlying operating system and window system; specifically, Adobe Type Manager (ATM) or a TrueType rasterizer under MS Windows, or the facilities provided by X Windows. This ability augments, but does not replace, Ghostscript's own Type 1 rasterizer: Ghostscript may still use its own rasterizer for very large characters, characters that are clipped or transformed in unusual ways, and for output to devices other than the screen. <p> Ghostscript connects to these platform facilities through a driver-like interface called the xfont (external font) interface. Current xfont implementations are associated directly with device drivers; in a future release, Ghostscript may separate them, so that (for example) it will be possible to use the platform rasterizer when writing to a file. <p> Please note that from this point, this file is likely to be useful only to a small number of Ghostscript porters and implementors. <hr> <h2><a name="Types"></a>Types</h2> <table cellpadding=0 cellspacing=0> <tr> <th valign=bottom align=left>Type <td> <th valign=bottom align=left>Declared /<br>defined in <td> <th valign=bottom align=left>Represents <tr> <td colspan=5><hr> <tr> <td valign=top><b><tt>gs_char</tt></b> <td> <td valign=top><b><tt>gsccode.h</tt></b> <td> <td valign=top>A character code that appears in a string. Currently it is always a single byte, but composite fonts or Unicode may require it to be wider in the future. <tr> <td valign=top><b><tt>gs_glyph</tt></b> <td> <td valign=top><b><tt>gsccode.h</tt></b> <td> <td valign=top>A character name like "period" or "epsilon". From the xfont implementation's point of view, it is just a handle; when necessary, Ghostscript provides a <b><tt>gs_proc_glyph_name_t</tt></b> procedure to convert it to a string name. <tr> <td valign=top><b><tt>gs_proc_glyph_name_t</tt></b> <td> <td valign=top><b><tt>gsccode.h</tt></b> <td> <td valign=top>A procedure that maps a <b><tt>gs_glyph</tt></b> to its string name; see the <b><tt>char_xglyph</tt></b> procedure. <tr> <td valign=top><b><tt>gx_xglyph</tt></b> <td> <td valign=top><b><tt>gsxfont.h</tt></b> <td> <td valign=top>A character or glyph code that can be used with a specific platform font. Normally it will be a character code that the implementation of <b><tt>render_char</tt></b> will turn into a 1-character string and give to the platform's "display string" operation. <tr> <td valign=top><b><tt>gx_xfont_procs</tt></b> <td> <td valign=top><b><tt>gsxfont.h</tt></b>, <b><tt>gxxfont.h</tt></b> <td> <td valign=top>The xfont analogue of <b><tt>gx_device_procs</tt></b>, the type of the procedure record that defines an xfont implementation. <tr> <td valign=top><b><tt>gx_xfont</tt></b> <td> <td valign=top><b><tt>gsxfont.h</tt></b>, <b><tt>gxxfont.h</tt></b> <td> <td valign=top>The gxfont analogue of <b><tt>gx_device</tt></b>, the type of the basic structure for an xfont. <tr> <td valign=top>(<b><tt>encoding_index</tt></b>) <td> <td> <td> <td valign=top>Not really a type, although it probably should be: an <b><tt>int</tt></b> used to indicate the <b><tt>Encoding</tt></b> used by a font. Defined values are <dl compact> <dt>0<dd><b><tt>StandardEncoding</tt></b> <dt>1<dd><b><tt>ISOLatin1Encoding</tt></b> <dt>2<dd><b><tt>SymbolEncoding</tt></b> <dt>3<dd><b><tt>DingbatsEncoding</tt></b> <dt>-1<dd>Other encoding </dl> </table> <hr> <h2><a name="Implementation_procedures"></a>Implementation procedures</h2> <p> All the procedures that return <b><tt>int</tt></b> results return 0 on success, or an appropriate negative error code for error conditions; these error codes are defined in <b><tt>gserrors.h</tt></b>. The relevant ones are the same as for <a href="Drivers.htm">drivers</a>, and as with drivers, if an implementation procedure returns an error, it should use the <b><tt>return_error</tt></b> macro -- defined in <b><tt>gx.h</tt></b>, which is automatically included by <b><tt>gdevprn.h</tt></b> but not by <b><tt>gserrors.h</tt></b> -- rather than a simple <b><tt>return</tt></b> statement, for instance <blockquote> <b><tt>return_error(gs_error_VMerror);</tt></b> </blockquote> <h2><a name="Font_level_procedures"></a>Font-level procedures</h2> <h3><a name="lookup_font"></a><b><tt>lookup_font</tt></b></h3> <dl> <dt><b><tt>gx_xfont *(*lookup_font)(P7(gx_device *dev, const byte *fname, uint len, int encoding_index, const gs_uid *puid, const gs_matrix *pmat, const gs_memory_procs *mprocs))</tt></b> <dd>Look up a font name, <b><tt>UniqueID</tt></b>, and matrix, and return an xfont, or <b><tt>NULL</tt></b> if no suitable xfont exists. Use <b><tt>mprocs</tt></b> to allocate the xfont and any subsidiary data structures. The matrix is the <b><tt>FontMatrix</tt></b> concatenated with the CTM, so (roughly speaking) the font size in pixels is <b><tt>pmat -> yy</tt></b> × 1000 for a normal Type 1 font. <p> Note that this is the only implementation procedure that does not take an xfont * as its first argument. In fact, callers of <b><tt>lookup_font</tt></b> must use the <b><tt>get_xfont_device</tt></b> driver procedure to get the correct device to pass as the first argument to <b><tt>lookup_font</tt></b>. </dl> <h3><a name="char_xglyph"></a><b><tt>char_xglyph</tt></b></h3> <dl> <dt><b><tt>gx_xglyph (*char_xglyph)(P5(gx_xfont *xf, gs_char chr, int encoding_index, gs_glyph glyph, gs_proc_glyph_name_t glyph_name))</tt></b> <dd>Convert a character name to an xglyph code. In the case of <b><tt>glyphshow</tt></b>, <b><tt>chr</tt></b> may be <b><tt>gs_no_char</tt></b>; for an ordinary <b><tt>show</tt></b> operation, if the character code is invalid, <b><tt>glyph</tt></b> may be <b><tt>gs_no_glyph</tt></b>. </dl> <h3><a name="char_metrics"></a><b><tt>char_metrics</tt></b></h3> <dl> <dt><b><tt>int (*char_metrics)(P5(gx_xfont *xf, gx_xglyph xg, int wmode, gs_int_point *pwidth, gs_int_rect *pbbox))</tt></b> <dd>Get the metrics for a character. If the metrics are unavailable, return 1. </dl> <h3><a name="render_char"></a><b><tt>render_char</tt></b></h3> <dl> <dt><b><tt>int (*render_char)(P7(gx_xfont *xf, gx_xglyph xg, gx_device *target, int x, int y, gx_color_index color, int required))</tt></b> <dd>Render a character. <em>(x,y)</em> corresponds to the character origin. The target may be any Ghostscript device. A good implementation will check whether the target can handle this type of xfont directly (for instance by checking the target name), and if so, will render the character directly; otherwise, it will do what has to be done in the general case, namely, get a bitmap for the character and use the target's <b><tt>copy_mono</tt></b> operation. If <b><tt>required</tt></b> is false, the procedure should return an error if the rendering operation would be expensive, since in this case Ghostscript has already cached the bitmap and metrics from a previous call with <b><tt>required</tt></b>=true. If the operation cannot be done, return 1. </dl> <h3><a name="release"></a><b><tt>release</tt></b></h3> <dl> <dt><b><tt>int (*release)(P2(gx_xfont *xf, const gs_memory_procs *mprocs))</tt></b> <dd>Release any external resources associated with an xfont. If <b><tt>mprocs</tt></b> is not <b><tt>NULL</tt></b>, also free any storage allocated by <b><tt>lookup_font</tt></b> (including the xfont itself). </dl> <!-- [2.0 end contents] ==================================================== --> <!-- [3.0 begin visible trailer] =========================================== --> <hr> <p> <small>Copyright © 1996, 1997, 1998 Aladdin Enterprises. All rights reserved.</small> <p> This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of the license contained in the file LICENSE in this distribution. For more information about licensing, please refer to http://www.ghostscript.com/licensing/. For information on commercial licensing, go to http://www.artifex.com/licensing/ or contact Artifex Software, Inc., 101 Lucas Valley Road #110, San Rafael, CA 94903, U.S.A., +1(415)492-9861. <p> <small>Ghostscript version 8.53, 20 October 2005 <!-- [3.0 end visible trailer] ============================================= --> </body> </html>