1/*********************************************************** 2Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 3 4 All Rights Reserved 5 6Permission to use, copy, modify, and distribute this software and its 7documentation for any purpose and without fee is hereby granted, 8provided that the above copyright notice appear in all copies and that 9both that copyright notice and this permission notice appear in 10supporting documentation, and that the name of Digital not be 11used in advertising or publicity pertaining to distribution of the 12software without specific, written prior permission. 13 14DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 15ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 16DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 17ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 18WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 19ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 20SOFTWARE. 21 22******************************************************************/ 23 24/* 25 26Copyright 1994, 1998 The Open Group 27 28Permission to use, copy, modify, distribute, and sell this software and its 29documentation for any purpose is hereby granted without fee, provided that 30the above copyright notice appear in all copies and that both that 31copyright notice and this permission notice appear in supporting 32documentation. 33 34The above copyright notice and this permission notice shall be included 35in all copies or substantial portions of the Software. 36 37THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 38OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 39MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 40IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 41OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 42ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 43OTHER DEALINGS IN THE SOFTWARE. 44 45Except as contained in this notice, the name of The Open Group shall 46not be used in advertising or otherwise to promote the sale, use or 47other dealings in this Software without prior written authorization 48from The Open Group. 49 50*/ 51 52#ifndef SNFSTR_H 53#define SNFSTR_H 1 54 55#include <X11/fonts/fntfilio.h> 56 57/*- 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. 62 * 2) font converters 63 * 64 * Each font file contains the following 65 * data structures, with no padding in-between. 66 * 67 * 1) The XFONTINFO structure 68 * hand-padded to a two-short boundary. 69 * maxbounds.byteoffset is the total number of bytes in the 70 * glpyh array 71 * maxbounds.bitOffset is thetotal width of the unpadded font 72 * 73 * 2) The XCHARINFO array 74 * indexed directly with character codes, both on disk 75 * and in memory. 76 * 77 * 3) Character glyphs 78 * padded in the server-natural way, and 79 * ordered in the device-natural way. 80 * End of glyphs padded to 32-bit boundary. 81 * 82 * 4) nProps font properties 83 * 84 * 5) a sequence of null-terminated strings, for font properties 85 */ 86 87#define FONT_FILE_VERSION 4 88 89typedef struct _snfFontProp { 90 CARD32 name; /* offset of string */ 91 INT32 value; /* number or offset of string */ 92 Bool indirect; /* value is a string offset */ 93} snfFontPropRec; 94 95/* 96 * the following macro definitions describe a font file image in memory 97 */ 98#define ADDRCharInfoRec( pfi) \ 99 ((snfCharInfoRec *) &(pfi)[1]) 100 101#define ADDRCHARGLYPHS( pfi) \ 102 (((char *) &(pfi)[1]) + BYTESOFCHARINFO(pfi)) 103 104/* 105 * pad out glyphs to a CARD32 boundary 106 */ 107#define ADDRXFONTPROPS( pfi) \ 108 ((snfFontPropRec *) ((char *)ADDRCHARGLYPHS( pfi) + BYTESOFGLYPHINFO(pfi))) 109 110#define ADDRSTRINGTAB( pfi) \ 111 ((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi)) 112 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)) 121 122typedef struct _snfFontProp *snfFontPropPtr; 123typedef struct _snfCharInfo *snfCharInfoPtr; 124typedef struct _snfFontInfo *snfFontInfoPtr; 125 126typedef 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 */ 131} snfCharInfoRec; 132 133typedef 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 == 145 * fontDescent */ 146 unsigned int linear:1; /* true if firstRow == lastRow */ 147 unsigned int constantWidth:1; /* true if 148 * minbounds->metrics.characterWidth 149 * == 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 <= 155 * fontDescent */ 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; 164 unsigned int nProps; 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 173 * positioning */ 174 unsigned int version2; /* version stamp double-check */ 175} snfFontInfoRec; 176 177extern void SnfSetFormat ( int bit, int byte, int glyph, int scan ); 178extern int snfReadFont ( FontPtr pFont, FontFilePtr file, 179 int bit, int byte, int glyph, int scan ); 180extern int snfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file ); 181 182#endif /* SNFSTR_H */ 183