Debian Codegraph @

texk/ps2pk/fontstruct.h

raw
1 /* $Header: fontstruct.h,v 1.10 91/07/22 15:37:41 keith Exp $ */
2 /***********************************************************
3 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
4 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
5
6 All Rights Reserved
7
8 Permission to use, copy, modify, and distribute this software and its
9 documentation for any purpose and without fee is hereby granted,
10 provided that the above copyright notice appear in all copies and that
11 both that copyright notice and this permission notice appear in
12 supporting documentation, and that the names of Digital or MIT not be
13 used in advertising or publicity pertaining to distribution of the
14 software without specific, written prior permission.
15
16 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
17 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
18 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
19 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
22 SOFTWARE.
23
24 @(#)fontstruct.h 3.2 91/04/15
25
26 ******************************************************************/
27
28 #ifndef FONTSTR_H
29 #define FONTSTR_H
30
31 #ifdef XSERVER
32 #include <X11/Xproto.h>
33 #else
34 #include "Xstuff.h"
35 #endif
36
37 #include "font.h"
38
39 /*
40 * This version of the server font data strucutre is only for describing
41 * the in memory data structure. The file structure is not necessarily a
42 * copy of this. That is up to the compiler and the OS layer font loading
43 * machinery.
44 */
45
46 #define GLYPHPADOPTIONS 4 /* 1, 2, 4, or 8 */
47
48 typedef enum {
49 Linear8Bit, TwoD8Bit, Linear16Bit, TwoD16Bit
50 } FontEncoding;
51
52 typedef struct _FontProp {
53 long name;
54 intptr_t value; /* large enough to hole an 'int' or 'void *' */
55 } FontPropRec;
56
57 typedef struct _FontResolution {
58 unsigned short x_resolution;
59 unsigned short y_resolution;
60 unsigned short point_size;
61 } FontResolutionRec;
62
63 typedef struct _ExtentInfo {
64 DrawDirection drawDirection;
65 int fontAscent;
66 int fontDescent;
67 int overallAscent;
68 int overallDescent;
69 int overallWidth;
70 int overallLeft;
71 int overallRight;
72 } ExtentInfoRec;
73
74 typedef struct _CharInfo {
75 xCharInfo metrics; /* info preformatted for Queries */
76 char *bits; /* pointer to glyph image */
77 } CharInfoRec;
78
79 /*
80 * Font is created at font load time. It is specific to a single encoding.
81 * e.g. not all of the glyphs in a font may be part of a single encoding.
82 */
83
84 typedef struct _FontInfo {
85 unsigned short firstCol;
86 unsigned short lastCol;
87 unsigned short firstRow;
88 unsigned short lastRow;
89 unsigned short defaultCh;
90 unsigned int noOverlap:1;
91 unsigned int terminalFont:1;
92 unsigned int constantMetrics:1;
93 unsigned int constantWidth:1;
94 unsigned int inkInside:1;
95 unsigned int inkMetrics:1;
96 unsigned int allExist:1;
97 unsigned int drawDirection:2;
98 unsigned int cachable:1;
99 unsigned int anamorphic:1;
100 short maxOverlap;
101 short pad;
102 xCharInfo maxbounds;
103 xCharInfo minbounds;
104 xCharInfo ink_maxbounds;
105 xCharInfo ink_minbounds;
106 short fontAscent;
107 short fontDescent;
108 int nprops;
109 FontPropPtr props;
110 char *isStringProp;
111 } FontInfoRec;
112
113 typedef struct _Font {
114 int refcnt;
115 FontInfoRec info;
116 char bit;
117 char byte;
118 char glyph;
119 char scan;
120 fsBitmapFormat format;
121 int (*get_glyphs) ( /* font, count, chars, encoding, count, glyphs */
122 struct _Font *pFont, uint32_t count,
123 unsigned char *chars, FontEncoding charEncoding,
124 uint32_t *glyphCount,
125 struct _CharInfo **glyphs );
126 int (*get_metrics) ( /* font, count, chars, encoding, count, glyphs */
127 FontPtr pFont, uint32_t count,
128 register unsigned char *chars,
129 FontEncoding charEncoding,
130 uint32_t *glyphCount,
131 xCharInfo **glyphs );
132 int (*get_bitmaps) (/* client, font, flags, ranges, nranges,
133 nextents, extents */ );
134 int (*get_extents) (/* client, font, format, flags, ranges,
135 nranges, nglyphs, offsets, glyphs */ );
136 void (*unload_font) ( FontPtr pFont /* font */ );
137 FontPathElementPtr fpe;
138 pointer svrPrivate;
139 pointer fontPrivate;
140 pointer fpePrivate;
141 int maxPrivate;
142 pointer *devPrivates;
143 } FontRec;
144
145 extern Bool _FontSetNewPrivate (/* pFont, n, ptr */);
146 extern int AllocateFontPrivateIndex ();
147
148 #define FontGetPrivate(pFont,n) ((n) > (pFont)->maxPrivate ? (pointer) 0 : \
149 (pFont)->devPrivates[n])
150
151 #define FontSetPrivate(pFont,n,ptr) ((n) > (pFont)->maxPrivate ? \
152 _FontSetNewPrivate (pFont, n, ptr) : \
153 ((((pFont)->devPrivates[n] = (ptr)) != 0) || TRUE))
154
155 typedef struct _FontNames {
156 int nnames;
157 int size;
158 int *length;
159 char **names;
160 } FontNamesRec;
161
162 /* External view of font paths */
163 typedef struct _FontPathElement {
164 int name_length;
165 char *name;
166 int type;
167 int refcount;
168 pointer private;
169 } FontPathElementRec;
170
171 typedef struct _FPEFunctions {
172 int (*name_check) ( /* name */ );
173 int (*init_fpe) ( /* fpe */ );
174 int (*reset_fpe) ( /* fpe */ );
175 int (*free_fpe) ( /* fpe */ );
176 int (*open_font) ( /* client, fpe, flags, name, namelen, format,
177 fid, ppfont, alias */ );
178 int (*close_font) ( /* pfont */ );
179 int (*list_fonts) ( /* client, fpe, pattern, patlen, maxnames,
180 paths */ );
181 int (*start_list_fonts_with_info) ( /* client, fpe, name, namelen,
182 maxnames, data */ );
183 int (*list_next_font_with_info) ( /* client, fpe, name, namelen,
184 info, num, data */ );
185 int (*wakeup_fpe) ( /* fpe, mask */ );
186 int (*client_died) ( /* client, fpe */ );
187 } FPEFunctionsRec, FPEFunctions;
188
189 extern int InitFPETypes();
190
191 /*
192 * Various macros for computing values based on contents of
193 * the above structures
194 */
195
196 #define GLYPHWIDTHPIXELS(pci) \
197 ((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
198
199 #define GLYPHHEIGHTPIXELS(pci) \
200 ((pci)->metrics.ascent + (pci)->metrics.descent)
201
202 #define GLYPHWIDTHBYTES(pci) (((GLYPHWIDTHPIXELS(pci))+7) >> 3)
203
204 #define GLYPHWIDTHPADDED(bc) (((bc)+7) & ~0x7)
205
206 #define BYTES_PER_ROW(bits, nbytes) \
207 ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
208 :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
209 :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
210 :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
211 : 0)
212
213 #define BYTES_FOR_GLYPH(ci,pad) (GLYPHHEIGHTPIXELS(ci) * \
214 BYTES_PER_ROW(GLYPHWIDTHPIXELS(ci),pad))
215 /*
216 * Macros for computing different bounding boxes for fonts; from
217 * the font protocol
218 */
219
220 #define FONT_MAX_ASCENT(pi) ((pi)->fontAscent > (pi)->ink_maxbounds.ascent ? \
221 (pi)->fontAscent : (pi)->ink_maxbounds.ascent)
222 #define FONT_MAX_DESCENT(pi) ((pi)->fontDescent > (pi)->ink_maxbounds.descent ? \
223 (pi)->fontDescent : (pi)->ink_maxbounds.descent)
224 #define FONT_MAX_HEIGHT(pi) (FONT_MAX_ASCENT(pi) + FONT_MAX_DESCENT(pi))
225 #define FONT_MIN_LEFT(pi) ((pi)->ink_minbounds.leftSideBearing < 0 ? \
226 (pi)->ink_minbounds.leftSideBearing : 0)
227 #define FONT_MAX_RIGHT(pi) ((pi)->ink_maxbounds.rightSideBearing > \
228 (pi)->ink_maxbounds.characterWidth ? \
229 (pi)->ink_maxbounds.rightSideBearing : \
230 (pi)->ink_maxbounds.characterWidth)
231 #define FONT_MAX_WIDTH(pi) (FONT_MAX_RIGHT(pi) - FONT_MIN_LEFT(pi))
232
233 #endif /* FONTSTR_H */