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 ******************************************************************/
26 Copyright 1994, 1998 The Open Group
28 Permission to use, copy, modify, distribute, and sell this software and its
29 documentation for any purpose is hereby granted without fee, provided that
30 the above copyright notice appear in all copies and that both that
31 copyright notice and this permission notice appear in supporting
34 The above copyright notice and this permission notice shall be included
35 in all copies or substantial portions of the Software.
37 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
38 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
40 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
41 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
42 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
43 OTHER DEALINGS IN THE SOFTWARE.
45 Except as contained in this notice, the name of The Open Group shall
46 not be used in advertising or otherwise to promote the sale, use or
47 other dealings in this Software without prior written authorization
55 #include <X11/fonts/fntfilio.h>
58 * This file describes the Server Natural Font format.
59 * SNF fonts are both CPU-dependent and frame buffer bit order dependent.
60 * This file is used by:
61 * 1) the server, to hold font information read out of font files.
64 * Each font file contains the following
65 * data structures, with no padding in-between.
67 * 1) The XFONTINFO structure
68 * hand-padded to a two-short boundary.
69 * maxbounds.byteoffset is the total number of bytes in the
71 * maxbounds.bitOffset is thetotal width of the unpadded font
73 * 2) The XCHARINFO array
74 * indexed directly with character codes, both on disk
78 * padded in the server-natural way, and
79 * ordered in the device-natural way.
80 * End of glyphs padded to 32-bit boundary.
82 * 4) nProps font properties
84 * 5) a sequence of null-terminated strings, for font properties
87 #define FONT_FILE_VERSION 4
89 typedef struct _snfFontProp {
90 CARD32 name; /* offset of string */
91 INT32 value; /* number or offset of string */
92 Bool indirect; /* value is a string offset */
96 * the following macro definitions describe a font file image in memory
98 #define ADDRCharInfoRec( pfi) \
99 ((snfCharInfoRec *) &(pfi)[1])
101 #define ADDRCHARGLYPHS( pfi) \
102 (((char *) &(pfi)[1]) + BYTESOFCHARINFO(pfi))
105 * pad out glyphs to a CARD32 boundary
107 #define ADDRXFONTPROPS( pfi) \
108 ((snfFontPropRec *) ((char *)ADDRCHARGLYPHS( pfi) + BYTESOFGLYPHINFO(pfi)))
110 #define ADDRSTRINGTAB( pfi) \
111 ((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi))
113 #define n2dChars(pfi) (((pfi)->lastRow - (pfi)->firstRow + 1) * \
114 ((pfi)->lastCol - (pfi)->firstCol + 1))
115 #define BYTESOFFONTINFO(pfi) (sizeof(snfFontInfoRec))
116 #define BYTESOFCHARINFO(pfi) (sizeof(snfCharInfoRec) * n2dChars(pfi))
117 #define BYTESOFPROPINFO(pfi) (sizeof(snfFontPropRec) * (pfi)->nProps)
118 #define BYTESOFSTRINGINFO(pfi) ((pfi)->lenStrings)
119 #define BYTESOFGLYPHINFO(pfi) (((pfi)->maxbounds.byteOffset+3) & ~0x3)
120 #define BYTESOFINKINFO(pfi) (sizeof(snfCharInfoRec) * n2dChars(pfi))
122 typedef struct _snfFontProp *snfFontPropPtr;
123 typedef struct _snfCharInfo *snfCharInfoPtr;
124 typedef struct _snfFontInfo *snfFontInfoPtr;
126 typedef struct _snfCharInfo {
127 xCharInfo metrics; /* info preformatted for Queries */
128 unsigned byteOffset:24; /* byte offset of the raster from pGlyphs */
129 unsigned exists:1; /* true iff glyph exists for this char */
130 unsigned pad:7; /* must be zero for now */
133 typedef struct _snfFontInfo {
134 unsigned int version1; /* version stamp */
135 unsigned int allExist;
136 unsigned int drawDirection;
137 unsigned int noOverlap; /* true if:
138 * max(rightSideBearing-characterWidth) <=
139 * minbounds->metrics.leftSideBearing */
140 unsigned int constantMetrics;
141 unsigned int terminalFont; /* Should be deprecated! true if: constant
142 * metrics && leftSideBearing == 0 &&
143 * rightSideBearing == characterWidth &&
144 * ascent == fontAscent && descent ==
146 unsigned int linear:1; /* true if firstRow == lastRow */
147 unsigned int constantWidth:1; /* true if
148 * minbounds->metrics.characterWidth
150 * maxbounds->metrics.characterWidth */
151 unsigned int inkInside:1; /* true if for all defined glyphs:
152 * leftSideBearing >= 0 && rightSideBearing <=
153 * characterWidth && -fontDescent <= ascent <=
154 * fontAscent && -fontAscent <= descent <=
156 unsigned int inkMetrics:1; /* ink metrics != bitmap metrics */
157 /* used with terminalFont */
158 /* see font's pInk{CI,Min,Max} */
159 unsigned int padding:28;
160 unsigned int firstCol;
161 unsigned int lastCol;
162 unsigned int firstRow;
163 unsigned int lastRow;
165 unsigned int lenStrings; /* length in bytes of string table */
166 unsigned int chDefault; /* default character */
167 int fontDescent; /* minimum for quality typography */
168 int fontAscent; /* minimum for quality typography */
169 snfCharInfoRec minbounds; /* MIN of glyph metrics over all chars */
170 snfCharInfoRec maxbounds; /* MAX of glyph metrics over all chars */
171 unsigned int pixDepth; /* intensity bits per pixel */
172 unsigned int glyphSets; /* number of sets of glyphs, for sub-pixel
174 unsigned int version2; /* version stamp double-check */
177 extern void SnfSetFormat ( int bit, int byte, int glyph, int scan );
178 extern int snfReadFont ( FontPtr pFont, FontFilePtr file,
179 int bit, int byte, int glyph, int scan );
180 extern int snfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file );
182 #endif /* SNFSTR_H */