1 /* $XConsortium: fontstruct.h /main/17 1996/08/09 16:23:54 kaleb $ */
2 /* $XFree86: xc/include/fonts/fontstruct.h,v 3.1 1996/12/23 05:58:39 dawes Exp $ */
3 /***********************************************************
4 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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 name of Digital not be
13 used in advertising or publicity pertaining to distribution of the
14 software without specific, written prior permission.
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
24 ******************************************************************/
29 #include <X11/Xproto.h>
31 #include <X11/Xfuncproto.h>
34 * This version of the server font data strucutre is only for describing
35 * the in memory data structure. The file structure is not necessarily a
36 * copy of this. That is up to the compiler and the OS layer font loading
40 #define GLYPHPADOPTIONS 4 /* 1, 2, 4, or 8 */
42 typedef struct _FontProp {
44 long value; /* assumes ATOM is not larger than INT32 */
47 typedef struct _FontResolution {
48 unsigned short x_resolution;
49 unsigned short y_resolution;
50 unsigned short point_size;
53 typedef struct _ExtentInfo {
54 DrawDirection drawDirection;
64 typedef struct _CharInfo {
65 xCharInfo metrics; /* info preformatted for Queries */
66 char *bits; /* pointer to glyph image */
70 * Font is created at font load time. It is specific to a single encoding.
71 * e.g. not all of the glyphs in a font may be part of a single encoding.
74 typedef struct _FontInfo {
75 unsigned short firstCol;
76 unsigned short lastCol;
77 unsigned short firstRow;
78 unsigned short lastRow;
79 unsigned short defaultCh;
80 unsigned int noOverlap:1;
81 unsigned int terminalFont:1;
82 unsigned int constantMetrics:1;
83 unsigned int constantWidth:1;
84 unsigned int inkInside:1;
85 unsigned int inkMetrics:1;
86 unsigned int allExist:1;
87 unsigned int drawDirection:2;
88 unsigned int cachable:1;
89 unsigned int anamorphic:1;
94 xCharInfo ink_maxbounds;
95 xCharInfo ink_minbounds;
103 typedef struct _Font {
110 fsBitmapFormat format;
112 #if NeedNestedPrototypes
114 unsigned long /* count */,
115 unsigned char * /* chars */,
116 FontEncoding /* encoding */,
117 unsigned long * /* count */,
118 CharInfoPtr * /* glyphs */
122 #if NeedNestedPrototypes
124 unsigned long /* count */,
125 unsigned char * /* chars */,
126 FontEncoding /* encoding */,
127 unsigned long * /* count */,
128 xCharInfo ** /* glyphs */
131 void (*unload_font) (
132 #if NeedNestedPrototypes
136 void (*unload_glyphs) (
137 #if NeedNestedPrototypes
141 FontPathElementPtr fpe;
146 pointer *devPrivates;
149 extern Bool _FontSetNewPrivate (
150 #if NeedFunctionPrototypes
156 extern int AllocateFontPrivateIndex (
157 #if NeedFunctionPrototypes
162 #define FontGetPrivate(pFont,n) ((n) > (pFont)->maxPrivate ? (pointer) 0 : \
163 (pFont)->devPrivates[n])
165 #define FontSetPrivate(pFont,n,ptr) ((n) > (pFont)->maxPrivate ? \
166 _FontSetNewPrivate (pFont, n, ptr) : \
167 ((((pFont)->devPrivates[n] = (ptr)) != 0) || TRUE))
169 typedef struct _FontNames {
176 /* External view of font paths */
177 typedef struct _FontPathElement {
183 } FontPathElementRec;
185 typedef struct _FPEFunctions {
187 #if NeedFunctionPrototypes
192 #if NeedNestedPrototypes
193 FontPathElementPtr /* fpe */
197 #if NeedNestedPrototypes
198 FontPathElementPtr /* fpe */
202 #if NeedNestedPrototypes
203 FontPathElementPtr /* fpe */
207 #if NeedNestedPrototypes
208 pointer /* client */,
209 FontPathElementPtr /* fpe */,
213 fsBitmapFormat /* format */,
214 fsBitmapFormatMask /* fmask */,
215 unsigned long /* id (type XID or FSID) */,
216 FontPtr* /* pFont */,
217 char** /* aliasName */,
218 FontPtr /* non_cachable_font */
223 #if NeedNestedPrototypes
224 FontPathElementPtr /* fpe */,
229 #if NeedNestedPrototypes
230 pointer /* client */,
231 FontPathElementPtr /* fpe */,
235 FontNamesPtr /* names */
238 int (*start_list_fonts_and_aliases) (
239 #if NeedNestedPrototypes
240 pointer /* client */,
241 FontPathElementPtr /* fpe */,
245 pointer* /* privatep */
248 int (*list_next_font_or_alias) (
249 #if NeedNestedPrototypes
250 pointer /* client */,
251 FontPathElementPtr /* fpe */,
254 char** /* resolvedp */,
255 int* /* resolvedlenp */,
256 pointer /* private */
259 int (*start_list_fonts_with_info) (
260 #if NeedNestedPrototypes
261 pointer /* client */,
262 FontPathElementPtr /* fpe */,
266 pointer* /* privatep */
269 int (*list_next_font_with_info) ( /* client, fpe, name, namelen,
271 #if NeedNestedPrototypes
272 pointer /* client */,
273 FontPathElementPtr /* fpe */,
276 FontInfoPtr* /* info */,
278 pointer /* private */
282 #if NeedNestedPrototypes
283 FontPathElementPtr /* fpe */,
284 unsigned long* /* LastSelectMask */
288 #if NeedNestedPrototypes
289 pointer /* client */,
290 FontPathElementPtr /* fpe */
293 /* for load_glyphs, range_flag = 0 ->
294 nchars = # of characters in data
295 item_size = bytes/char
296 data = list of characters
298 nchars = # of fsChar2b's in data
300 data = list of fsChar2b's */
302 #if NeedNestedPrototypes
303 pointer /* client */,
305 Bool /* range_flag */,
306 unsigned int /* nchars */,
308 unsigned char* /* data */
311 void (*set_path_hook)(
312 #if NeedFunctionPrototypes
316 } FPEFunctionsRec, FPEFunctions;
319 extern int InitFPETypes();
323 * Various macros for computing values based on contents of
324 * the above structures
327 #define GLYPHWIDTHPIXELS(pci) \
328 ((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
330 #define GLYPHHEIGHTPIXELS(pci) \
331 ((pci)->metrics.ascent + (pci)->metrics.descent)
333 #define GLYPHWIDTHBYTES(pci) (((GLYPHWIDTHPIXELS(pci))+7) >> 3)
335 #define GLYPHWIDTHPADDED(bc) (((bc)+7) & ~0x7)
337 #define BYTES_PER_ROW(bits, nbytes) \
338 ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
339 :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
340 :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
341 :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
344 #define BYTES_FOR_GLYPH(ci,pad) (GLYPHHEIGHTPIXELS(ci) * \
345 BYTES_PER_ROW(GLYPHWIDTHPIXELS(ci),pad))
347 * Macros for computing different bounding boxes for fonts; from
351 #define FONT_MAX_ASCENT(pi) ((pi)->fontAscent > (pi)->ink_maxbounds.ascent ? \
352 (pi)->fontAscent : (pi)->ink_maxbounds.ascent)
353 #define FONT_MAX_DESCENT(pi) ((pi)->fontDescent > (pi)->ink_maxbounds.descent ? \
354 (pi)->fontDescent : (pi)->ink_maxbounds.descent)
355 #define FONT_MAX_HEIGHT(pi) (FONT_MAX_ASCENT(pi) + FONT_MAX_DESCENT(pi))
356 #define FONT_MIN_LEFT(pi) ((pi)->ink_minbounds.leftSideBearing < 0 ? \
357 (pi)->ink_minbounds.leftSideBearing : 0)
358 #define FONT_MAX_RIGHT(pi) ((pi)->ink_maxbounds.rightSideBearing > \
359 (pi)->ink_maxbounds.characterWidth ? \
360 (pi)->ink_maxbounds.rightSideBearing : \
361 (pi)->ink_maxbounds.characterWidth)
362 #define FONT_MAX_WIDTH(pi) (FONT_MAX_RIGHT(pi) - FONT_MIN_LEFT(pi))
364 #endif /* FONTSTR_H */