1/*
2
3Copyright 1991, 1998  The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included
12in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall
23not be used in advertising or otherwise to promote the sale, use or
24other dealings in this Software without prior written authorization
25from The Open Group.
26
27*/
28
29/*
30 * Author:  Keith Packard, MIT X Consortium
31 */
32
33#ifndef _PCF_H_
34#define _PCF_H_
35
36#include "fntfilio.h"
37
38/*
39 * Information used to read/write PCF fonts
40 */
41
42typedef struct _PCFTable {
43    CARD32      type;
44    CARD32      format;
45    CARD32      size;
46    CARD32      offset;
47} PCFTableRec, *PCFTablePtr;
48
49#define PCF_FILE_VERSION	(('p'<<24) | ('c'<<16) | ('f'<<8) | 1)
50#define	PCF_FORMAT_MASK		0xffffff00
51
52#define PCF_DEFAULT_FORMAT	0x00000000
53#define PCF_INKBOUNDS		0x00000200
54#define PCF_ACCEL_W_INKBOUNDS	0x00000100
55#define PCF_COMPRESSED_METRICS	0x00000100
56
57#define PCF_FORMAT_MATCH(a,b)	(((a)&PCF_FORMAT_MASK) == ((b)&PCF_FORMAT_MASK))
58
59#define PCF_GLYPH_PAD_MASK	(3<<0)
60#define PCF_BYTE_MASK		(1<<2)
61#define PCF_BIT_MASK		(1<<3)
62#define PCF_SCAN_UNIT_MASK	(3<<4)
63
64#define PCF_BYTE_ORDER(f)	(((f) & PCF_BYTE_MASK)?MSBFirst:LSBFirst)
65#define PCF_BIT_ORDER(f)	(((f) & PCF_BIT_MASK)?MSBFirst:LSBFirst)
66#define PCF_GLYPH_PAD_INDEX(f)	((f) & PCF_GLYPH_PAD_MASK)
67#define PCF_GLYPH_PAD(f)	(1<<PCF_GLYPH_PAD_INDEX(f))
68#define PCF_SCAN_UNIT_INDEX(f)	(((f) & PCF_SCAN_UNIT_MASK) >> 4)
69#define PCF_SCAN_UNIT(f)	(1<<PCF_SCAN_UNIT_INDEX(f))
70#define PCF_FORMAT_BITS(f) \
71    ((f) & (PCF_GLYPH_PAD_MASK|PCF_BYTE_MASK|PCF_BIT_MASK|PCF_SCAN_UNIT_MASK))
72
73#define PCF_SIZE_TO_INDEX(s)	((s) == 4 ? 2 : (s) == 2 ? 1 : 0)
74#define PCF_INDEX_TO_SIZE(b)	(1<<b)
75
76#define PCF_FORMAT(bit,byte,glyph,scan) (\
77    (PCF_SIZE_TO_INDEX(scan) << 4) | \
78    (((bit) == MSBFirst ? 1 : 0) << 3) | \
79    (((byte) == MSBFirst ? 1 : 0) << 2) | \
80    (PCF_SIZE_TO_INDEX(glyph) << 0))
81
82#define PCF_PROPERTIES		    (1<<0)
83#define PCF_ACCELERATORS	    (1<<1)
84#define PCF_METRICS		    (1<<2)
85#define PCF_BITMAPS		    (1<<3)
86#define PCF_INK_METRICS		    (1<<4)
87#define	PCF_BDF_ENCODINGS	    (1<<5)
88#define PCF_SWIDTHS		    (1<<6)
89#define PCF_GLYPH_NAMES		    (1<<7)
90#define PCF_BDF_ACCELERATORS	    (1<<8)
91
92extern int pcfReadFont(FontPtr pFont, FontFilePtr file,
93                       int bit, int byte, int glyph, int scan);
94extern int pcfReadFontInfo(FontInfoPtr pFontInfo, FontFilePtr file);
95extern int pcfWriteFont(FontPtr pFont, FontFilePtr file);
96
97#endif                          /* _PCF_H_ */
98