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