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