1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gxxfont.h 8250 2007-09-25 13:31:24Z giles $ */
15
/* External font interface for Ghostscript library */
17
#ifndef gxxfont_INCLUDED
18
# define gxxfont_INCLUDED
26
* Design issues for external fonts
28
* 1. Where do xfonts come from: a device or a font service?
30
* 2. Is a given xfont associated with a particular device, or with a
31
* class of devices, which may have different output media?
32
* (Specifically, Windows displays vs. printers.)
34
* 3. Is an xfont a handle that must be interpreted by its originator,
35
* or an object with its own set of operations?
37
* 4. Are xfonts always transformation-specific, or is there such a thing
38
* as a scalable xfont?
40
* 5. What is the meaning of the transformation matrix supplied when
41
* asking for an xfont?
43
* Answers (for the current design)
45
* 1. Devices supply xfonts. Internal devices (image, null, clipping,
46
* command list, tracing) forward font requests to a real underlying
47
* device. File format devices should do the same, but right now
50
* 2. An xfont is not associated with anything: it just provides bitmaps.
51
* Since xfonts are only used at small sizes and low resolutions,
52
* tuning differences for different output media aren't likely to be
55
* 3. Xfonts are objects. They are allocated by their originator, and
56
* (currently) only freed by `restore'.
58
* 4. Xfonts are always transformation-specific. This may lead to some
59
* clutter, but it's very unlikely that a document will have enough
60
* different transformed versions of a single font for this to be a
61
* problem in practice.
63
* 5. The transformation matrix is the CTM within the BuildChar or BuildGlyph
64
* procedure. This maps a 1000x1000 square to the intended character size
65
* (assuming the base font uses the usual 1000-unit scaling).
68
/* The definitions for xfonts are very similar to those for devices. */
70
/* Structure for generic xfonts. */
71
typedef struct gx_xfont_common_s {
72
const gx_xfont_procs *procs;
75
/* A generic xfont. */
77
gx_xfont_common common;
80
/* Definition of xfont procedures. */
82
struct gx_xfont_procs_s {
84
/* Look up a font name, UniqueID, and matrix, and return */
87
/* NOTE: even though this is defined as an xfont_proc, */
88
/* it is actually a `factory' procedure, the only one that */
89
/* does not take an xfont * as its first argument. */
91
#define xfont_proc_lookup_font(proc)\
92
gx_xfont *proc(gx_device *dev, const byte *fname, uint len,\
93
int encoding_index, const gs_uid *puid, const gs_matrix *pmat,\
95
xfont_proc_lookup_font((*lookup_font));
98
* Convert a character name to an xglyph code. encoding_index is
99
* actually a gs_encoding_index_t. Either chr or glyph may be absent
100
* (gs_no_char/glyph), but not both. glyph_name is the glyph's
101
* (string) name if the glyph is not GS_NO_GLYPH and is not a CID.
104
* This procedure was deprecated as of release 3.43, but still
105
* supported. In release 7.21, the argument list was changed, and the
106
* procedure is no longer deprecated.
109
#define xfont_proc_char_xglyph(proc)\
110
gx_xglyph proc(gx_xfont *xf, gs_char chr, int encoding_index,\
111
gs_glyph glyph, const gs_const_string *glyph_name)
112
xfont_proc_char_xglyph((*char_xglyph));
114
/* Get the metrics for a character. */
115
/* Note: pwidth changed in release 2.9.7. */
117
#define xfont_proc_char_metrics(proc)\
118
int proc(gx_xfont *xf, gx_xglyph xg, int wmode,\
119
gs_point *pwidth, gs_int_rect *pbbox)
120
xfont_proc_char_metrics((*char_metrics));
122
/* Render a character. */
123
/* (x,y) corresponds to the character origin. */
124
/* The target may be any Ghostscript device. */
126
#define xfont_proc_render_char(proc)\
127
int proc(gx_xfont *xf, gx_xglyph xg, gx_device *target,\
128
int x, int y, gx_color_index color, int required)
129
xfont_proc_render_char((*render_char));
131
/* Release any external resources associated with an xfont. */
132
/* If mprocs is not NULL, also free any storage */
133
/* allocated by lookup_font (including the xfont itself). */
135
#define xfont_proc_release(proc)\
136
int proc(gx_xfont *xf, gs_memory_t *mem)
137
xfont_proc_release((*release));
139
/* (There was a char_xglyph2 procedure here, added in release 3.43, */
140
/* removed in 7.21.) */
145
* Since xfonts are garbage-collectable, they need structure descriptors.
146
* Fortunately, the common part of an xfont contains no pointers to
147
* GC-managed space, so simple xfonts can use gs_private_st_simple.
148
* The following macro will serve for an xfont with only one pointer,
151
#define gs__st_dev_ptrs1(scope_st, stname, stype, sname, penum, preloc, de)\
152
static ENUM_PTRS_WITH(penum, stype *xfptr) return 0;\
153
case 0: ENUM_RETURN(gx_device_enum_ptr((gx_device *)(xfptr->de)));\
155
static RELOC_PTRS_WITH(preloc, stype *xfptr) ;\
156
xfptr->de = (void *)gx_device_reloc_ptr((gx_device *)(xfptr->de), gcst);\
158
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
160
* We probably don't ever want xfont descriptors to be public....
161
#define gs_public_st_dev_ptrs1(stname, stype, sname, penum, preloc, de)\
162
gs__st_dev_ptrs1(public_st, stname, stype, sname, penum, preloc, de)
164
#define gs_private_st_dev_ptrs1(stname, stype, sname, penum, preloc, de)\
165
gs__st_dev_ptrs1(private_st, stname, stype, sname, penum, preloc, de)
167
#endif /* gxxfont_INCLUDED */