blob: af0ffc33781691fda2cffc52d83abaf934d38610 [file] [log] [blame]
Werner Lemberg93616ec2001-06-27 19:46:12 +00001/* pcf.h
Werner Lembergf28b7bf2001-01-01 17:24:31 +00002
3 FreeType font driver for pcf fonts
4
Joel Klingheded913c22010-12-31 16:59:33 +01005 Copyright (C) 2000, 2001, 2002, 2003, 2006, 2010 by
Werner Lemberg93616ec2001-06-27 19:46:12 +00006 Francesco Zappa Nardelli
Werner Lembergf28b7bf2001-01-01 17:24:31 +00007
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE SOFTWARE.
25*/
26
27
28#ifndef __PCF_H__
29#define __PCF_H__
30
31
32#include <ft2build.h>
33#include FT_INTERNAL_DRIVER_H
David Turner54b0bca2002-10-31 22:19:27 +000034#include FT_INTERNAL_STREAM_H
Werner Lembergf28b7bf2001-01-01 17:24:31 +000035
36
37FT_BEGIN_HEADER
38
39 typedef struct PCF_TableRec_
40 {
41 FT_ULong type;
42 FT_ULong format;
43 FT_ULong size;
44 FT_ULong offset;
45
46 } PCF_TableRec, *PCF_Table;
47
48
Werner Lemberg93616ec2001-06-27 19:46:12 +000049 typedef struct PCF_TocRec_
Werner Lembergf28b7bf2001-01-01 17:24:31 +000050 {
51 FT_ULong version;
52 FT_ULong count;
53 PCF_Table tables;
54
55 } PCF_TocRec, *PCF_Toc;
56
57
David Turnerf39b7a02002-03-14 09:30:52 +000058 typedef struct PCF_ParsePropertyRec_
Werner Lembergf28b7bf2001-01-01 17:24:31 +000059 {
60 FT_Long name;
61 FT_Byte isString;
62 FT_Long value;
63
64 } PCF_ParsePropertyRec, *PCF_ParseProperty;
65
66
David Turnerf39b7a02002-03-14 09:30:52 +000067 typedef struct PCF_PropertyRec_
Werner Lembergf28b7bf2001-01-01 17:24:31 +000068 {
69 FT_String* name;
70 FT_Byte isString;
71
72 union
73 {
74 FT_String* atom;
suzuki toshiyab61d9282009-08-01 00:30:23 +090075 FT_Long l;
76 FT_ULong ul;
Werner Lembergf28b7bf2001-01-01 17:24:31 +000077
78 } value;
79
Werner Lemberg93616ec2001-06-27 19:46:12 +000080 } PCF_PropertyRec, *PCF_Property;
Werner Lembergf28b7bf2001-01-01 17:24:31 +000081
82
David Turnerf39b7a02002-03-14 09:30:52 +000083 typedef struct PCF_Compressed_MetricRec_
Werner Lembergf28b7bf2001-01-01 17:24:31 +000084 {
85 FT_Byte leftSideBearing;
86 FT_Byte rightSideBearing;
87 FT_Byte characterWidth;
88 FT_Byte ascent;
89 FT_Byte descent;
90
91 } PCF_Compressed_MetricRec, *PCF_Compressed_Metric;
Werner Lembergf28b7bf2001-01-01 17:24:31 +000092
Werner Lemberg93616ec2001-06-27 19:46:12 +000093
David Turnerf39b7a02002-03-14 09:30:52 +000094 typedef struct PCF_MetricRec_
Werner Lembergf28b7bf2001-01-01 17:24:31 +000095 {
96 FT_Short leftSideBearing;
97 FT_Short rightSideBearing;
98 FT_Short characterWidth;
99 FT_Short ascent;
100 FT_Short descent;
101 FT_Short attributes;
102 FT_ULong bits;
103
104 } PCF_MetricRec, *PCF_Metric;
105
106
107 typedef struct PCF_AccelRec_
108 {
109 FT_Byte noOverlap;
110 FT_Byte constantMetrics;
111 FT_Byte terminalFont;
112 FT_Byte constantWidth;
113 FT_Byte inkInside;
114 FT_Byte inkMetrics;
115 FT_Byte drawDirection;
116 FT_Long fontAscent;
117 FT_Long fontDescent;
118 FT_Long maxOverlap;
119 PCF_MetricRec minbounds;
120 PCF_MetricRec maxbounds;
121 PCF_MetricRec ink_minbounds;
122 PCF_MetricRec ink_maxbounds;
123
124 } PCF_AccelRec, *PCF_Accel;
125
126
David Turnerb6b63372003-04-09 06:55:57 +0000127 typedef struct PCF_EncodingRec_
Werner Lembergf28b7bf2001-01-01 17:24:31 +0000128 {
David Turnerb6b63372003-04-09 06:55:57 +0000129 FT_Long enc;
130 FT_UShort glyph;
Werner Lembergf28b7bf2001-01-01 17:24:31 +0000131
132 } PCF_EncodingRec, *PCF_Encoding;
133
134
135 typedef struct PCF_FaceRec_
136 {
137 FT_FaceRec root;
Werner Lemberg93616ec2001-06-27 19:46:12 +0000138
Joel Klingheded913c22010-12-31 16:59:33 +0100139 FT_StreamRec comp_stream;
140 FT_Stream comp_source;
David Turner54b0bca2002-10-31 22:19:27 +0000141
Werner Lembergf28b7bf2001-01-01 17:24:31 +0000142 char* charset_encoding;
143 char* charset_registry;
144
145 PCF_TocRec toc;
146 PCF_AccelRec accel;
147
148 int nprops;
149 PCF_Property properties;
150
151 FT_Long nmetrics;
152 PCF_Metric metrics;
153 FT_Long nencodings;
154 PCF_Encoding encodings;
Werner Lemberg93616ec2001-06-27 19:46:12 +0000155
Werner Lembergf28b7bf2001-01-01 17:24:31 +0000156 FT_Short defaultChar;
157
158 FT_ULong bitmapsFormat;
159
160 FT_CharMap charmap_handle;
161 FT_CharMapRec charmap; /* a single charmap per face */
162
163 } PCF_FaceRec, *PCF_Face;
164
165
Werner Lembergf28b7bf2001-01-01 17:24:31 +0000166 /* macros for pcf font format */
167
168#define LSBFirst 0
169#define MSBFirst 1
170
171#define PCF_FILE_VERSION ( ( 'p' << 24 ) | \
172 ( 'c' << 16 ) | \
173 ( 'f' << 8 ) | 1 )
Werner Lembergf1c2b912006-01-13 14:53:28 +0000174#define PCF_FORMAT_MASK 0xFFFFFF00UL
Werner Lemberg93616ec2001-06-27 19:46:12 +0000175
Werner Lembergf1c2b912006-01-13 14:53:28 +0000176#define PCF_DEFAULT_FORMAT 0x00000000UL
177#define PCF_INKBOUNDS 0x00000200UL
178#define PCF_ACCEL_W_INKBOUNDS 0x00000100UL
179#define PCF_COMPRESSED_METRICS 0x00000100UL
Werner Lembergf28b7bf2001-01-01 17:24:31 +0000180
181#define PCF_FORMAT_MATCH( a, b ) \
182 ( ( (a) & PCF_FORMAT_MASK ) == ( (b) & PCF_FORMAT_MASK ) )
183
184#define PCF_GLYPH_PAD_MASK ( 3 << 0 )
185#define PCF_BYTE_MASK ( 1 << 2 )
186#define PCF_BIT_MASK ( 1 << 3 )
187#define PCF_SCAN_UNIT_MASK ( 3 << 4 )
188
189#define PCF_BYTE_ORDER( f ) \
190 ( ( (f) & PCF_BYTE_MASK ) ? MSBFirst : LSBFirst )
191#define PCF_BIT_ORDER( f ) \
192 ( ( (f) & PCF_BIT_MASK ) ? MSBFirst : LSBFirst )
193#define PCF_GLYPH_PAD_INDEX( f ) \
194 ( (f) & PCF_GLYPH_PAD_MASK )
195#define PCF_GLYPH_PAD( f ) \
196 ( 1 << PCF_GLYPH_PAD_INDEX( f ) )
197#define PCF_SCAN_UNIT_INDEX( f ) \
198 ( ( (f) & PCF_SCAN_UNIT_MASK ) >> 4 )
199#define PCF_SCAN_UNIT( f ) \
200 ( 1 << PCF_SCAN_UNIT_INDEX( f ) )
201#define PCF_FORMAT_BITS( f ) \
202 ( (f) & ( PCF_GLYPH_PAD_MASK | \
203 PCF_BYTE_MASK | \
204 PCF_BIT_MASK | \
205 PCF_SCAN_UNIT_MASK ) )
206
207#define PCF_SIZE_TO_INDEX( s ) ( (s) == 4 ? 2 : (s) == 2 ? 1 : 0 )
208#define PCF_INDEX_TO_SIZE( b ) ( 1 << b )
209
210#define PCF_FORMAT( bit, byte, glyph, scan ) \
211 ( ( PCF_SIZE_TO_INDEX( scan ) << 4 ) | \
212 ( ( (bit) == MSBFirst ? 1 : 0 ) << 3 ) | \
213 ( ( (byte) == MSBFirst ? 1 : 0 ) << 2 ) | \
214 ( PCF_SIZE_TO_INDEX( glyph ) << 0 ) )
215
216#define PCF_PROPERTIES ( 1 << 0 )
217#define PCF_ACCELERATORS ( 1 << 1 )
218#define PCF_METRICS ( 1 << 2 )
219#define PCF_BITMAPS ( 1 << 3 )
220#define PCF_INK_METRICS ( 1 << 4 )
221#define PCF_BDF_ENCODINGS ( 1 << 5 )
222#define PCF_SWIDTHS ( 1 << 6 )
223#define PCF_GLYPH_NAMES ( 1 << 7 )
224#define PCF_BDF_ACCELERATORS ( 1 << 8 )
225
226#define GLYPHPADOPTIONS 4 /* I'm not sure about this */
227
David Turnerbc82f1b2002-03-01 02:26:22 +0000228 FT_LOCAL( FT_Error )
Werner Lemberg93616ec2001-06-27 19:46:12 +0000229 pcf_load_font( FT_Stream,
230 PCF_Face );
231
Werner Lembergf28b7bf2001-01-01 17:24:31 +0000232FT_END_HEADER
233
234#endif /* __PCF_H__ */
235
236
237/* END */