snfstr.h revision 23a0898a
1/* $Xorg: snfstr.h,v 1.4 2001/02/09 02:04:02 xorgcvs Exp $ */ 2/*********************************************************** 3Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 4 5 All Rights Reserved 6 7Permission to use, copy, modify, and distribute this software and its 8documentation for any purpose and without fee is hereby granted, 9provided that the above copyright notice appear in all copies and that 10both that copyright notice and this permission notice appear in 11supporting documentation, and that the name of Digital not be 12used in advertising or publicity pertaining to distribution of the 13software without specific, written prior permission. 14 15DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 16ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 17DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 18ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 19WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 20ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 21SOFTWARE. 22 23******************************************************************/ 24 25/* 26 27Copyright 1994, 1998 The Open Group 28 29Permission to use, copy, modify, distribute, and sell this software and its 30documentation for any purpose is hereby granted without fee, provided that 31the above copyright notice appear in all copies and that both that 32copyright notice and this permission notice appear in supporting 33documentation. 34 35The above copyright notice and this permission notice shall be included 36in all copies or substantial portions of the Software. 37 38THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 39OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 40MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 41IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 42OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 43ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 44OTHER DEALINGS IN THE SOFTWARE. 45 46Except as contained in this notice, the name of The Open Group shall 47not be used in advertising or otherwise to promote the sale, use or 48other dealings in this Software without prior written authorization 49from The Open Group. 50 51*/ 52/* $XFree86: xc/lib/font/bitmap/snfstr.h,v 1.5 2001/12/14 19:56:47 dawes Exp $ */ 53 54#ifndef SNFSTR_H 55#define SNFSTR_H 1 56 57#include <X11/fonts/fntfilio.h> 58 59/*- 60 * This file describes the Server Natural Font format. 61 * SNF fonts are both CPU-dependent and frame buffer bit order dependent. 62 * This file is used by: 63 * 1) the server, to hold font information read out of font files. 64 * 2) font converters 65 * 66 * Each font file contains the following 67 * data structures, with no padding in-between. 68 * 69 * 1) The XFONTINFO structure 70 * hand-padded to a two-short boundary. 71 * maxbounds.byteoffset is the total number of bytes in the 72 * glpyh array 73 * maxbounds.bitOffset is thetotal width of the unpadded font 74 * 75 * 2) The XCHARINFO array 76 * indexed directly with character codes, both on disk 77 * and in memory. 78 * 79 * 3) Character glyphs 80 * padded in the server-natural way, and 81 * ordered in the device-natural way. 82 * End of glyphs padded to 32-bit boundary. 83 * 84 * 4) nProps font properties 85 * 86 * 5) a sequence of null-terminated strings, for font properties 87 */ 88 89#define FONT_FILE_VERSION 4 90 91typedef struct _snfFontProp { 92 CARD32 name; /* offset of string */ 93 INT32 value; /* number or offset of string */ 94 Bool indirect; /* value is a string offset */ 95} snfFontPropRec; 96 97/* 98 * the following macro definitions describe a font file image in memory 99 */ 100#define ADDRCharInfoRec( pfi) \ 101 ((snfCharInfoRec *) &(pfi)[1]) 102 103#define ADDRCHARGLYPHS( pfi) \ 104 (((char *) &(pfi)[1]) + BYTESOFCHARINFO(pfi)) 105 106/* 107 * pad out glyphs to a CARD32 boundary 108 */ 109#define ADDRXFONTPROPS( pfi) \ 110 ((snfFontPropRec *) ((char *)ADDRCHARGLYPHS( pfi) + BYTESOFGLYPHINFO(pfi))) 111 112#define ADDRSTRINGTAB( pfi) \ 113 ((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi)) 114 115#define n2dChars(pfi) (((pfi)->lastRow - (pfi)->firstRow + 1) * \ 116 ((pfi)->lastCol - (pfi)->firstCol + 1)) 117#define BYTESOFFONTINFO(pfi) (sizeof(snfFontInfoRec)) 118#define BYTESOFCHARINFO(pfi) (sizeof(snfCharInfoRec) * n2dChars(pfi)) 119#define BYTESOFPROPINFO(pfi) (sizeof(snfFontPropRec) * (pfi)->nProps) 120#define BYTESOFSTRINGINFO(pfi) ((pfi)->lenStrings) 121#define BYTESOFGLYPHINFO(pfi) (((pfi)->maxbounds.byteOffset+3) & ~0x3) 122#define BYTESOFINKINFO(pfi) (sizeof(snfCharInfoRec) * n2dChars(pfi)) 123 124typedef struct _snfFontProp *snfFontPropPtr; 125typedef struct _snfCharInfo *snfCharInfoPtr; 126typedef struct _snfFontInfo *snfFontInfoPtr; 127 128typedef struct _snfCharInfo { 129 xCharInfo metrics; /* info preformatted for Queries */ 130 unsigned byteOffset:24; /* byte offset of the raster from pGlyphs */ 131 unsigned exists:1; /* true iff glyph exists for this char */ 132 unsigned pad:7; /* must be zero for now */ 133} snfCharInfoRec; 134 135typedef struct _snfFontInfo { 136 unsigned int version1; /* version stamp */ 137 unsigned int allExist; 138 unsigned int drawDirection; 139 unsigned int noOverlap; /* true if: 140 * max(rightSideBearing-characterWidth) <= 141 * minbounds->metrics.leftSideBearing */ 142 unsigned int constantMetrics; 143 unsigned int terminalFont; /* Should be deprecated! true if: constant 144 * metrics && leftSideBearing == 0 && 145 * rightSideBearing == characterWidth && 146 * ascent == fontAscent && descent == 147 * fontDescent */ 148 unsigned int linear:1; /* true if firstRow == lastRow */ 149 unsigned int constantWidth:1; /* true if 150 * minbounds->metrics.characterWidth 151 * == 152 * maxbounds->metrics.characterWidth */ 153 unsigned int inkInside:1; /* true if for all defined glyphs: 154 * leftSideBearing >= 0 && rightSideBearing <= 155 * characterWidth && -fontDescent <= ascent <= 156 * fontAscent && -fontAscent <= descent <= 157 * fontDescent */ 158 unsigned int inkMetrics:1; /* ink metrics != bitmap metrics */ 159 /* used with terminalFont */ 160 /* see font's pInk{CI,Min,Max} */ 161 unsigned int padding:28; 162 unsigned int firstCol; 163 unsigned int lastCol; 164 unsigned int firstRow; 165 unsigned int lastRow; 166 unsigned int nProps; 167 unsigned int lenStrings; /* length in bytes of string table */ 168 unsigned int chDefault; /* default character */ 169 int fontDescent; /* minimum for quality typography */ 170 int fontAscent; /* minimum for quality typography */ 171 snfCharInfoRec minbounds; /* MIN of glyph metrics over all chars */ 172 snfCharInfoRec maxbounds; /* MAX of glyph metrics over all chars */ 173 unsigned int pixDepth; /* intensity bits per pixel */ 174 unsigned int glyphSets; /* number of sets of glyphs, for sub-pixel 175 * positioning */ 176 unsigned int version2; /* version stamp double-check */ 177} snfFontInfoRec; 178 179extern void SnfSetFormat ( int bit, int byte, int glyph, int scan ); 180extern int snfReadFont ( FontPtr pFont, FontFilePtr file, 181 int bit, int byte, int glyph, int scan ); 182extern int snfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file ); 183 184#endif /* SNFSTR_H */ 185