a5fdbcd0105245b56cba6bd5c7a12b89ede4de9e
[framework/uifw/xorg/lib/libxfont.git] / include / X11 / fonts / pcf.h
1 /*
2
3 Copyright 1991, 1998  The Open Group
4
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
25 from 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 <X11/fonts/fntfilio.h>
37
38 /*
39  * Information used to read/write PCF fonts
40  */
41
42 typedef 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)      ((f) & (PCF_GLYPH_PAD_MASK|PCF_BYTE_MASK|PCF_BIT_MASK|PCF_SCAN_UNIT_MASK))
71
72 #define PCF_SIZE_TO_INDEX(s)    ((s) == 4 ? 2 : (s) == 2 ? 1 : 0)
73 #define PCF_INDEX_TO_SIZE(b)    (1<<b)
74
75 #define PCF_FORMAT(bit,byte,glyph,scan) (\
76     (PCF_SIZE_TO_INDEX(scan) << 4) | \
77     (((bit) == MSBFirst ? 1 : 0) << 3) | \
78     (((byte) == MSBFirst ? 1 : 0) << 2) | \
79     (PCF_SIZE_TO_INDEX(glyph) << 0))
80
81 #define PCF_PROPERTIES              (1<<0)
82 #define PCF_ACCELERATORS            (1<<1)
83 #define PCF_METRICS                 (1<<2)
84 #define PCF_BITMAPS                 (1<<3)
85 #define PCF_INK_METRICS             (1<<4)
86 #define PCF_BDF_ENCODINGS           (1<<5)
87 #define PCF_SWIDTHS                 (1<<6)
88 #define PCF_GLYPH_NAMES             (1<<7)
89 #define PCF_BDF_ACCELERATORS        (1<<8)
90
91 extern int pcfReadFont ( FontPtr pFont, FontFilePtr file, 
92                          int bit, int byte, int glyph, int scan );
93 extern int pcfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file );
94 extern int pcfWriteFont ( FontPtr pFont, FontFilePtr file );
95 extern void pcfError ( const char *, ... );
96
97 #endif                          /* _PCF_H_ */