1 /***********************************************************
2 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
6 Permission to use, copy, modify, and distribute this software and its
7 documentation for any purpose and without fee is hereby granted,
8 provided that the above copyright notice appear in all copies and that
9 both that copyright notice and this permission notice appear in
10 supporting documentation, and that the name of Digital not be
11 used in advertising or publicity pertaining to distribution of the
12 software without specific, written prior permission.
14 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
22 ******************************************************************/
27 #include <X11/Xproto.h>
29 #include <X11/Xfuncproto.h>
30 #include <X11/Xdefs.h>
33 * This version of the server font data strucutre is only for describing
34 * the in memory data structure. The file structure is not necessarily a
35 * copy of this. That is up to the compiler and the OS layer font loading
39 #define GLYPHPADOPTIONS 4 /* 1, 2, 4, or 8 */
41 typedef struct _FontProp {
43 long value; /* assumes ATOM is not larger than INT32 */
46 typedef struct _FontResolution {
47 unsigned short x_resolution;
48 unsigned short y_resolution;
49 unsigned short point_size;
52 typedef struct _ExtentInfo {
53 DrawDirection drawDirection;
63 typedef struct _CharInfo {
64 xCharInfo metrics; /* info preformatted for Queries */
65 char *bits; /* pointer to glyph image */
69 * Font is created at font load time. It is specific to a single encoding.
70 * e.g. not all of the glyphs in a font may be part of a single encoding.
73 typedef struct _FontInfo {
74 unsigned short firstCol;
75 unsigned short lastCol;
76 unsigned short firstRow;
77 unsigned short lastRow;
78 unsigned short defaultCh;
79 unsigned int noOverlap:1;
80 unsigned int terminalFont:1;
81 unsigned int constantMetrics:1;
82 unsigned int constantWidth:1;
83 unsigned int inkInside:1;
84 unsigned int inkMetrics:1;
85 unsigned int allExist:1;
86 unsigned int drawDirection:2;
87 unsigned int cachable:1;
88 unsigned int anamorphic:1;
93 xCharInfo ink_maxbounds;
94 xCharInfo ink_minbounds;
102 typedef struct _Font {
109 fsBitmapFormat format;
110 int (*get_glyphs) (FontPtr /* font */,
111 unsigned long /* count */,
112 unsigned char * /* chars */,
113 FontEncoding /* encoding */,
114 unsigned long * /* count */,
115 CharInfoPtr * /* glyphs */);
116 int (*get_metrics) (FontPtr /* font */,
117 unsigned long /* count */,
118 unsigned char * /* chars */,
119 FontEncoding /* encoding */,
120 unsigned long * /* count */,
121 xCharInfo ** /* glyphs */);
122 void (*unload_font) (FontPtr /* font */);
123 void (*unload_glyphs) (FontPtr /* font */);
124 FontPathElementPtr fpe;
132 #define FontGetPrivate(pFont,n) ((n) > (pFont)->maxPrivate ? (void *) 0 : \
133 (pFont)->devPrivates[n])
135 #define FontSetPrivate(pFont,n,ptr) ((n) > (pFont)->maxPrivate ? \
136 _FontSetNewPrivate (pFont, n, ptr) : \
137 ((((pFont)->devPrivates[n] = (ptr)) != 0) || TRUE))
139 typedef struct _FontNames {
147 /* External view of font paths */
148 typedef struct _FontPathElement {
150 #if FONT_PATH_ELEMENT_NAME_CONST
157 } FontPathElementRec;
159 typedef Bool (*NameCheckFunc) (const char *name);
160 typedef int (*InitFpeFunc) (FontPathElementPtr fpe);
161 typedef int (*FreeFpeFunc) (FontPathElementPtr fpe);
162 typedef int (*ResetFpeFunc) (FontPathElementPtr fpe);
163 typedef int (*OpenFontFunc) ( void *client,
164 FontPathElementPtr fpe,
168 fsBitmapFormat format,
169 fsBitmapFormatMask fmask,
173 FontPtr non_cachable_font);
174 typedef void (*CloseFontFunc) (FontPathElementPtr fpe, FontPtr pFont);
175 typedef int (*ListFontsFunc) (void *client,
176 FontPathElementPtr fpe,
182 typedef int (*StartLfwiFunc) (void *client,
183 FontPathElementPtr fpe,
189 typedef int (*NextLfwiFunc) (void *client,
190 FontPathElementPtr fpe,
197 typedef int (*WakeupFpeFunc) (FontPathElementPtr fpe,
198 unsigned long* LastSelectMask);
200 typedef void (*ClientDiedFunc) (void *client,
201 FontPathElementPtr fpe);
203 typedef int (*LoadGlyphsFunc) (void *client,
208 unsigned char* data);
210 typedef int (*StartLaFunc) (void *client,
211 FontPathElementPtr fpe,
217 typedef int (*NextLaFunc) (void *client,
218 FontPathElementPtr fpe,
225 typedef void (*SetPathFunc)(void);
227 typedef struct _FPEFunctions {
228 NameCheckFunc name_check;
229 InitFpeFunc init_fpe;
230 ResetFpeFunc reset_fpe;
231 FreeFpeFunc free_fpe;
232 OpenFontFunc open_font;
233 CloseFontFunc close_font;
234 ListFontsFunc list_fonts;
235 StartLaFunc start_list_fonts_and_aliases;
236 NextLaFunc list_next_font_or_alias;
237 StartLfwiFunc start_list_fonts_with_info;
238 NextLfwiFunc list_next_font_with_info;
239 WakeupFpeFunc wakeup_fpe;
240 ClientDiedFunc client_died;
241 /* for load_glyphs, range_flag = 0 ->
242 nchars = # of characters in data
243 item_size = bytes/char
244 data = list of characters
246 nchars = # of fsChar2b's in data
248 data = list of fsChar2b's */
249 LoadGlyphsFunc load_glyphs;
250 SetPathFunc set_path_hook;
251 } FPEFunctionsRec, FPEFunctions;
254 * Various macros for computing values based on contents of
255 * the above structures
258 #define GLYPHWIDTHPIXELS(pci) \
259 ((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
261 #define GLYPHHEIGHTPIXELS(pci) \
262 ((pci)->metrics.ascent + (pci)->metrics.descent)
264 #define GLYPHWIDTHBYTES(pci) (((GLYPHWIDTHPIXELS(pci))+7) >> 3)
266 #define GLYPHWIDTHPADDED(bc) (((bc)+7) & ~0x7)
268 #define BYTES_PER_ROW(bits, nbytes) \
269 ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
270 :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
271 :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
272 :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
275 #define BYTES_FOR_GLYPH(ci,pad) (GLYPHHEIGHTPIXELS(ci) * \
276 BYTES_PER_ROW(GLYPHWIDTHPIXELS(ci),pad))
278 * Macros for computing different bounding boxes for fonts; from
282 #define FONT_MAX_ASCENT(pi) ((pi)->fontAscent > (pi)->ink_maxbounds.ascent ? \
283 (pi)->fontAscent : (pi)->ink_maxbounds.ascent)
284 #define FONT_MAX_DESCENT(pi) ((pi)->fontDescent > (pi)->ink_maxbounds.descent ? \
285 (pi)->fontDescent : (pi)->ink_maxbounds.descent)
286 #define FONT_MAX_HEIGHT(pi) (FONT_MAX_ASCENT(pi) + FONT_MAX_DESCENT(pi))
287 #define FONT_MIN_LEFT(pi) ((pi)->ink_minbounds.leftSideBearing < 0 ? \
288 (pi)->ink_minbounds.leftSideBearing : 0)
289 #define FONT_MAX_RIGHT(pi) ((pi)->ink_maxbounds.rightSideBearing > \
290 (pi)->ink_maxbounds.characterWidth ? \
291 (pi)->ink_maxbounds.rightSideBearing : \
292 (pi)->ink_maxbounds.characterWidth)
293 #define FONT_MAX_WIDTH(pi) (FONT_MAX_RIGHT(pi) - FONT_MIN_LEFT(pi))
295 #include "fontproto.h"
297 #endif /* FONTSTR_H */