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