snfstr.h revision 23a0898a
123a0898aSmrg/* $Xorg: snfstr.h,v 1.4 2001/02/09 02:04:02 xorgcvs Exp $ */
223a0898aSmrg/***********************************************************
323a0898aSmrgCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
423a0898aSmrg
523a0898aSmrg                        All Rights Reserved
623a0898aSmrg
723a0898aSmrgPermission to use, copy, modify, and distribute this software and its
823a0898aSmrgdocumentation for any purpose and without fee is hereby granted,
923a0898aSmrgprovided that the above copyright notice appear in all copies and that
1023a0898aSmrgboth that copyright notice and this permission notice appear in
1123a0898aSmrgsupporting documentation, and that the name of Digital not be
1223a0898aSmrgused in advertising or publicity pertaining to distribution of the
1323a0898aSmrgsoftware without specific, written prior permission.
1423a0898aSmrg
1523a0898aSmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
1623a0898aSmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
1723a0898aSmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
1823a0898aSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
1923a0898aSmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
2023a0898aSmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
2123a0898aSmrgSOFTWARE.
2223a0898aSmrg
2323a0898aSmrg******************************************************************/
2423a0898aSmrg
2523a0898aSmrg/*
2623a0898aSmrg
2723a0898aSmrgCopyright 1994, 1998  The Open Group
2823a0898aSmrg
2923a0898aSmrgPermission to use, copy, modify, distribute, and sell this software and its
3023a0898aSmrgdocumentation for any purpose is hereby granted without fee, provided that
3123a0898aSmrgthe above copyright notice appear in all copies and that both that
3223a0898aSmrgcopyright notice and this permission notice appear in supporting
3323a0898aSmrgdocumentation.
3423a0898aSmrg
3523a0898aSmrgThe above copyright notice and this permission notice shall be included
3623a0898aSmrgin all copies or substantial portions of the Software.
3723a0898aSmrg
3823a0898aSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3923a0898aSmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4023a0898aSmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
4123a0898aSmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
4223a0898aSmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
4323a0898aSmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
4423a0898aSmrgOTHER DEALINGS IN THE SOFTWARE.
4523a0898aSmrg
4623a0898aSmrgExcept as contained in this notice, the name of The Open Group shall
4723a0898aSmrgnot be used in advertising or otherwise to promote the sale, use or
4823a0898aSmrgother dealings in this Software without prior written authorization
4923a0898aSmrgfrom The Open Group.
5023a0898aSmrg
5123a0898aSmrg*/
5223a0898aSmrg/* $XFree86: xc/lib/font/bitmap/snfstr.h,v 1.5 2001/12/14 19:56:47 dawes Exp $ */
5323a0898aSmrg
5423a0898aSmrg#ifndef SNFSTR_H
5523a0898aSmrg#define SNFSTR_H 1
5623a0898aSmrg
5723a0898aSmrg#include <X11/fonts/fntfilio.h>
5823a0898aSmrg
5923a0898aSmrg/*-
6023a0898aSmrg * This file describes the Server Natural Font format.
6123a0898aSmrg * SNF fonts are both CPU-dependent and frame buffer bit order dependent.
6223a0898aSmrg * This file is used by:
6323a0898aSmrg *	1)  the server, to hold font information read out of font files.
6423a0898aSmrg *	2)  font converters
6523a0898aSmrg *
6623a0898aSmrg * Each font file contains the following
6723a0898aSmrg * data structures, with no padding in-between.
6823a0898aSmrg *
6923a0898aSmrg *	1)  The XFONTINFO structure
7023a0898aSmrg *		hand-padded to a two-short boundary.
7123a0898aSmrg *		maxbounds.byteoffset is the total number of bytes in the
7223a0898aSmrg *			glpyh array
7323a0898aSmrg *		maxbounds.bitOffset is thetotal width of the unpadded font
7423a0898aSmrg *
7523a0898aSmrg *	2)  The XCHARINFO array
7623a0898aSmrg *		indexed directly with character codes, both on disk
7723a0898aSmrg *		and in memory.
7823a0898aSmrg *
7923a0898aSmrg *	3)  Character glyphs
8023a0898aSmrg *		padded in the server-natural way, and
8123a0898aSmrg *		ordered in the device-natural way.
8223a0898aSmrg *		End of glyphs padded to 32-bit boundary.
8323a0898aSmrg *
8423a0898aSmrg *	4)  nProps font properties
8523a0898aSmrg *
8623a0898aSmrg *	5)  a sequence of null-terminated strings, for font properties
8723a0898aSmrg */
8823a0898aSmrg
8923a0898aSmrg#define FONT_FILE_VERSION	4
9023a0898aSmrg
9123a0898aSmrgtypedef struct _snfFontProp {
9223a0898aSmrg    CARD32      name;		/* offset of string */
9323a0898aSmrg    INT32       value;		/* number or offset of string */
9423a0898aSmrg    Bool        indirect;	/* value is a string offset */
9523a0898aSmrg}           snfFontPropRec;
9623a0898aSmrg
9723a0898aSmrg/*
9823a0898aSmrg * the following macro definitions describe a font file image in memory
9923a0898aSmrg */
10023a0898aSmrg#define ADDRCharInfoRec( pfi)	\
10123a0898aSmrg	((snfCharInfoRec *) &(pfi)[1])
10223a0898aSmrg
10323a0898aSmrg#define ADDRCHARGLYPHS( pfi)	\
10423a0898aSmrg	(((char *) &(pfi)[1]) + BYTESOFCHARINFO(pfi))
10523a0898aSmrg
10623a0898aSmrg/*
10723a0898aSmrg * pad out glyphs to a CARD32 boundary
10823a0898aSmrg */
10923a0898aSmrg#define ADDRXFONTPROPS( pfi)  \
11023a0898aSmrg	((snfFontPropRec *) ((char *)ADDRCHARGLYPHS( pfi) + BYTESOFGLYPHINFO(pfi)))
11123a0898aSmrg
11223a0898aSmrg#define ADDRSTRINGTAB( pfi)  \
11323a0898aSmrg	((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi))
11423a0898aSmrg
11523a0898aSmrg#define n2dChars(pfi)	(((pfi)->lastRow - (pfi)->firstRow + 1) * \
11623a0898aSmrg			 ((pfi)->lastCol - (pfi)->firstCol + 1))
11723a0898aSmrg#define	BYTESOFFONTINFO(pfi)	(sizeof(snfFontInfoRec))
11823a0898aSmrg#define BYTESOFCHARINFO(pfi)	(sizeof(snfCharInfoRec) * n2dChars(pfi))
11923a0898aSmrg#define	BYTESOFPROPINFO(pfi)	(sizeof(snfFontPropRec) * (pfi)->nProps)
12023a0898aSmrg#define	BYTESOFSTRINGINFO(pfi)	((pfi)->lenStrings)
12123a0898aSmrg#define	BYTESOFGLYPHINFO(pfi)	(((pfi)->maxbounds.byteOffset+3) & ~0x3)
12223a0898aSmrg#define BYTESOFINKINFO(pfi)	(sizeof(snfCharInfoRec) * n2dChars(pfi))
12323a0898aSmrg
12423a0898aSmrgtypedef struct _snfFontProp *snfFontPropPtr;
12523a0898aSmrgtypedef struct _snfCharInfo *snfCharInfoPtr;
12623a0898aSmrgtypedef struct _snfFontInfo *snfFontInfoPtr;
12723a0898aSmrg
12823a0898aSmrgtypedef struct _snfCharInfo {
12923a0898aSmrg    xCharInfo   metrics;	/* info preformatted for Queries */
13023a0898aSmrg    unsigned    byteOffset:24;	/* byte offset of the raster from pGlyphs */
13123a0898aSmrg    unsigned    exists:1;	/* true iff glyph exists for this char */
13223a0898aSmrg    unsigned    pad:7;		/* must be zero for now */
13323a0898aSmrg}           snfCharInfoRec;
13423a0898aSmrg
13523a0898aSmrgtypedef struct _snfFontInfo {
13623a0898aSmrg    unsigned int version1;	/* version stamp */
13723a0898aSmrg    unsigned int allExist;
13823a0898aSmrg    unsigned int drawDirection;
13923a0898aSmrg    unsigned int noOverlap;	/* true if:
14023a0898aSmrg				 * max(rightSideBearing-characterWidth) <=
14123a0898aSmrg				 * minbounds->metrics.leftSideBearing */
14223a0898aSmrg    unsigned int constantMetrics;
14323a0898aSmrg    unsigned int terminalFont;	/* Should be deprecated!  true if: constant
14423a0898aSmrg				 * metrics && leftSideBearing == 0 &&
14523a0898aSmrg				 * rightSideBearing == characterWidth &&
14623a0898aSmrg				 * ascent == fontAscent && descent ==
14723a0898aSmrg				 * fontDescent */
14823a0898aSmrg    unsigned int linear:1;	/* true if firstRow == lastRow */
14923a0898aSmrg    unsigned int constantWidth:1;	/* true if
15023a0898aSmrg					 * minbounds->metrics.characterWidth
15123a0898aSmrg					 * ==
15223a0898aSmrg					 * maxbounds->metrics.characterWidth */
15323a0898aSmrg    unsigned int inkInside:1;	/* true if for all defined glyphs:
15423a0898aSmrg				 * leftSideBearing >= 0 && rightSideBearing <=
15523a0898aSmrg				 * characterWidth && -fontDescent <= ascent <=
15623a0898aSmrg				 * fontAscent && -fontAscent <= descent <=
15723a0898aSmrg				 * fontDescent */
15823a0898aSmrg    unsigned int inkMetrics:1;	/* ink metrics != bitmap metrics */
15923a0898aSmrg    /* used with terminalFont */
16023a0898aSmrg    /* see font's pInk{CI,Min,Max} */
16123a0898aSmrg    unsigned int padding:28;
16223a0898aSmrg    unsigned int firstCol;
16323a0898aSmrg    unsigned int lastCol;
16423a0898aSmrg    unsigned int firstRow;
16523a0898aSmrg    unsigned int lastRow;
16623a0898aSmrg    unsigned int nProps;
16723a0898aSmrg    unsigned int lenStrings;	/* length in bytes of string table */
16823a0898aSmrg    unsigned int chDefault;	/* default character */
16923a0898aSmrg    int         fontDescent;	/* minimum for quality typography */
17023a0898aSmrg    int         fontAscent;	/* minimum for quality typography */
17123a0898aSmrg    snfCharInfoRec minbounds;	/* MIN of glyph metrics over all chars */
17223a0898aSmrg    snfCharInfoRec maxbounds;	/* MAX of glyph metrics over all chars */
17323a0898aSmrg    unsigned int pixDepth;	/* intensity bits per pixel */
17423a0898aSmrg    unsigned int glyphSets;	/* number of sets of glyphs, for sub-pixel
17523a0898aSmrg				 * positioning */
17623a0898aSmrg    unsigned int version2;	/* version stamp double-check */
17723a0898aSmrg}           snfFontInfoRec;
17823a0898aSmrg
17923a0898aSmrgextern void SnfSetFormat ( int bit, int byte, int glyph, int scan );
18023a0898aSmrgextern int snfReadFont ( FontPtr pFont, FontFilePtr file,
18123a0898aSmrg			 int bit, int byte, int glyph, int scan );
18223a0898aSmrgextern int snfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file );
18323a0898aSmrg
18423a0898aSmrg#endif				/* SNFSTR_H */
185