misc fixes to get rrdtool working without included libraries.
[rrdtool.git] / libraries / freetype-2.0.5 / include / pcf.h
1 /*  pcf.h
2
3   FreeType font driver for pcf fonts
4
5   Copyright (C) 2000-2001 by
6   Francesco Zappa Nardelli
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 */
26
27
28 #ifndef __PCF_H__
29 #define __PCF_H__
30
31
32 #include <ft2build.h>
33 #include FT_INTERNAL_DRIVER_H
34
35
36 FT_BEGIN_HEADER
37
38   typedef struct  PCF_TableRec_
39   {
40     FT_ULong  type;
41     FT_ULong  format;
42     FT_ULong  size;
43     FT_ULong  offset;
44
45   } PCF_TableRec, *PCF_Table;
46
47
48   typedef struct  PCF_TocRec_
49   {
50     FT_ULong   version;
51     FT_ULong   count;
52     PCF_Table  tables;
53
54   } PCF_TocRec, *PCF_Toc;
55
56
57   typedef struct  PCF_ParseProperty_
58   {
59     FT_Long  name;
60     FT_Byte  isString;
61     FT_Long  value;
62
63   } PCF_ParsePropertyRec, *PCF_ParseProperty;
64
65
66   typedef struct  PCF_Property_
67   {
68     FT_String*  name;
69     FT_Byte     isString;
70
71     union
72     {
73       FT_String*  atom;
74       FT_Long     integer;
75       FT_ULong    cardinal;
76
77     } value;
78
79   } PCF_PropertyRec, *PCF_Property;
80
81
82   typedef struct  PCF_Compressed_Metric_
83   {
84     FT_Byte  leftSideBearing;
85     FT_Byte  rightSideBearing;
86     FT_Byte  characterWidth;
87     FT_Byte  ascent;
88     FT_Byte  descent;
89
90   } PCF_Compressed_MetricRec, *PCF_Compressed_Metric;
91
92
93   typedef struct  PCF_Metric_
94   {
95     FT_Short  leftSideBearing;
96     FT_Short  rightSideBearing;
97     FT_Short  characterWidth;
98     FT_Short  ascent;
99     FT_Short  descent;
100     FT_Short  attributes;
101     FT_ULong  bits;
102
103   } PCF_MetricRec, *PCF_Metric;
104
105
106   typedef struct  PCF_AccelRec_
107   {
108     FT_Byte        noOverlap;
109     FT_Byte        constantMetrics;
110     FT_Byte        terminalFont;
111     FT_Byte        constantWidth;
112     FT_Byte        inkInside;
113     FT_Byte        inkMetrics;
114     FT_Byte        drawDirection;
115     FT_Long        fontAscent;
116     FT_Long        fontDescent;
117     FT_Long        maxOverlap;
118     PCF_MetricRec  minbounds;
119     PCF_MetricRec  maxbounds;
120     PCF_MetricRec  ink_minbounds;
121     PCF_MetricRec  ink_maxbounds;
122
123   } PCF_AccelRec, *PCF_Accel;
124
125
126   typedef struct  PCD_Encoding_
127   {
128     FT_Long   enc;
129     FT_Short  glyph;
130
131   } PCF_EncodingRec, *PCF_Encoding;
132
133
134   typedef struct  PCF_FaceRec_
135   {
136     FT_FaceRec     root;
137
138     char*          charset_encoding;
139     char*          charset_registry;
140
141     PCF_TocRec     toc;
142     PCF_AccelRec   accel;
143
144     int            nprops;
145     PCF_Property   properties;
146
147     FT_Long        nmetrics;
148     PCF_Metric     metrics;
149     FT_Long        nencodings;
150     PCF_Encoding   encodings;
151
152     FT_Short       defaultChar;
153
154     FT_ULong       bitmapsFormat;
155
156     FT_CharMap     charmap_handle;
157     FT_CharMapRec  charmap;  /* a single charmap per face */
158
159   } PCF_FaceRec, *PCF_Face;
160
161
162   /* XXX hack */
163   FT_LOCAL FT_Error
164   PCF_Done_Face( PCF_Face  face );
165
166
167   /* macros for pcf font format */
168
169 #define LSBFirst  0
170 #define MSBFirst  1
171
172 #define PCF_FILE_VERSION        ( ( 'p' << 24 ) | \
173                                   ( 'c' << 16 ) | \
174                                   ( 'f' <<  8 ) | 1 )
175 #define PCF_FORMAT_MASK         0xFFFFFF00L
176
177 #define PCF_DEFAULT_FORMAT      0x00000000L
178 #define PCF_INKBOUNDS           0x00000200L
179 #define PCF_ACCEL_W_INKBOUNDS   0x00000100L
180 #define PCF_COMPRESSED_METRICS  0x00000100L
181
182 #define PCF_FORMAT_MATCH( a, b ) \
183           ( ( (a) & PCF_FORMAT_MASK ) == ( (b) & PCF_FORMAT_MASK ) )
184
185 #define PCF_GLYPH_PAD_MASK  ( 3 << 0 )
186 #define PCF_BYTE_MASK       ( 1 << 2 )
187 #define PCF_BIT_MASK        ( 1 << 3 )
188 #define PCF_SCAN_UNIT_MASK  ( 3 << 4 )
189
190 #define PCF_BYTE_ORDER( f ) \
191           ( ( (f) & PCF_BYTE_MASK ) ? MSBFirst : LSBFirst )
192 #define PCF_BIT_ORDER( f ) \
193           ( ( (f) & PCF_BIT_MASK ) ? MSBFirst : LSBFirst )
194 #define PCF_GLYPH_PAD_INDEX( f ) \
195           ( (f) & PCF_GLYPH_PAD_MASK )
196 #define PCF_GLYPH_PAD( f ) \
197           ( 1 << PCF_GLYPH_PAD_INDEX( f ) )
198 #define PCF_SCAN_UNIT_INDEX( f ) \
199           ( ( (f) & PCF_SCAN_UNIT_MASK ) >> 4 )
200 #define PCF_SCAN_UNIT( f ) \
201           ( 1 << PCF_SCAN_UNIT_INDEX( f ) )
202 #define PCF_FORMAT_BITS( f )             \
203           ( (f) & ( PCF_GLYPH_PAD_MASK | \
204                     PCF_BYTE_MASK      | \
205                     PCF_BIT_MASK       | \
206                     PCF_SCAN_UNIT_MASK ) )
207
208 #define PCF_SIZE_TO_INDEX( s )  ( (s) == 4 ? 2 : (s) == 2 ? 1 : 0 )
209 #define PCF_INDEX_TO_SIZE( b )  ( 1 << b )
210
211 #define PCF_FORMAT( bit, byte, glyph, scan )          \
212           ( ( PCF_SIZE_TO_INDEX( scan )      << 4 ) | \
213             ( ( (bit)  == MSBFirst ? 1 : 0 ) << 3 ) | \
214             ( ( (byte) == MSBFirst ? 1 : 0 ) << 2 ) | \
215             ( PCF_SIZE_TO_INDEX( glyph )     << 0 ) )
216
217 #define PCF_PROPERTIES        ( 1 << 0 )
218 #define PCF_ACCELERATORS      ( 1 << 1 )
219 #define PCF_METRICS           ( 1 << 2 )
220 #define PCF_BITMAPS           ( 1 << 3 )
221 #define PCF_INK_METRICS       ( 1 << 4 )
222 #define PCF_BDF_ENCODINGS     ( 1 << 5 )
223 #define PCF_SWIDTHS           ( 1 << 6 )
224 #define PCF_GLYPH_NAMES       ( 1 << 7 )
225 #define PCF_BDF_ACCELERATORS  ( 1 << 8 )
226
227 #define GLYPHPADOPTIONS  4 /* I'm not sure about this */
228
229   FT_LOCAL FT_Error
230   pcf_load_font( FT_Stream,
231                  PCF_Face );
232
233
234 FT_END_HEADER
235
236 #endif /* __PCF_H__ */
237
238
239 /* END */