• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*  pcf.h
2 
3   FreeType font driver for pcf fonts
4 
5   Copyright (C) 2000, 2001, 2002, 2003, 2006, 2010 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 <freetype/internal/ftdrv.h>
33 #include <freetype/internal/ftstream.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_ParsePropertyRec_
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_PropertyRec_
67   {
68     FT_String*  name;
69     FT_Byte     isString;
70 
71     union
72     {
73       FT_String*  atom;
74       FT_Long     l;
75       FT_ULong    ul;
76 
77     } value;
78 
79   } PCF_PropertyRec, *PCF_Property;
80 
81 
82   typedef struct  PCF_Compressed_MetricRec_
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_MetricRec_
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 
102     FT_ULong  bits;  /* offset into the PCF_BITMAPS table */
103 
104   } PCF_MetricRec, *PCF_Metric;
105 
106 
107   typedef struct  PCF_EncRec_
108   {
109     FT_UShort   firstCol;
110     FT_UShort   lastCol;
111     FT_UShort   firstRow;
112     FT_UShort   lastRow;
113     FT_UShort   defaultChar;
114 
115     FT_UShort*  offset;
116 
117   } PCF_EncRec, *PCF_Enc;
118 
119 
120   typedef struct  PCF_AccelRec_
121   {
122     FT_Byte        noOverlap;
123     FT_Byte        constantMetrics;
124     FT_Byte        terminalFont;
125     FT_Byte        constantWidth;
126     FT_Byte        inkInside;
127     FT_Byte        inkMetrics;
128     FT_Byte        drawDirection;
129     FT_Long        fontAscent;
130     FT_Long        fontDescent;
131     FT_Long        maxOverlap;
132     PCF_MetricRec  minbounds;
133     PCF_MetricRec  maxbounds;
134     PCF_MetricRec  ink_minbounds;
135     PCF_MetricRec  ink_maxbounds;
136 
137   } PCF_AccelRec, *PCF_Accel;
138 
139 
140   /*
141    * This file uses X11 terminology for PCF data; an `encoding' in X11 speak
142    * is the same as a `character code' in FreeType speak.
143    */
144   typedef struct  PCF_FaceRec_
145   {
146     FT_FaceRec    root;
147 
148     FT_StreamRec  comp_stream;
149     FT_Stream     comp_source;
150 
151     char*         charset_encoding;
152     char*         charset_registry;
153 
154     PCF_TocRec    toc;
155     PCF_AccelRec  accel;
156 
157     int           nprops;
158     PCF_Property  properties;
159 
160     FT_ULong      nmetrics;
161     PCF_Metric    metrics;
162 
163     PCF_EncRec    enc;
164 
165     FT_ULong      bitmapsFormat;
166 
167   } PCF_FaceRec, *PCF_Face;
168 
169 
170   typedef struct  PCF_DriverRec_
171   {
172     FT_DriverRec  root;
173 
174     FT_Bool  no_long_family_names;
175 
176   } PCF_DriverRec, *PCF_Driver;
177 
178 
179   /* macros for pcf font format */
180 
181 #define LSBFirst  0
182 #define MSBFirst  1
183 
184 #define PCF_FILE_VERSION        ( ( 'p' << 24 ) | \
185                                   ( 'c' << 16 ) | \
186                                   ( 'f' <<  8 ) | 1 )
187 #define PCF_FORMAT_MASK         0xFFFFFF00UL
188 
189 #define PCF_DEFAULT_FORMAT      0x00000000UL
190 #define PCF_INKBOUNDS           0x00000200UL
191 #define PCF_ACCEL_W_INKBOUNDS   0x00000100UL
192 #define PCF_COMPRESSED_METRICS  0x00000100UL
193 
194 #define PCF_FORMAT_MATCH( a, b ) \
195           ( ( (a) & PCF_FORMAT_MASK ) == ( (b) & PCF_FORMAT_MASK ) )
196 
197 #define PCF_GLYPH_PAD_MASK  ( 3 << 0 )
198 #define PCF_BYTE_MASK       ( 1 << 2 )
199 #define PCF_BIT_MASK        ( 1 << 3 )
200 #define PCF_SCAN_UNIT_MASK  ( 3 << 4 )
201 
202 #define PCF_BYTE_ORDER( f ) \
203           ( ( (f) & PCF_BYTE_MASK ) ? MSBFirst : LSBFirst )
204 #define PCF_BIT_ORDER( f ) \
205           ( ( (f) & PCF_BIT_MASK ) ? MSBFirst : LSBFirst )
206 #define PCF_GLYPH_PAD_INDEX( f ) \
207           ( (f) & PCF_GLYPH_PAD_MASK )
208 #define PCF_GLYPH_PAD( f ) \
209           ( 1 << PCF_GLYPH_PAD_INDEX( f ) )
210 #define PCF_SCAN_UNIT_INDEX( f ) \
211           ( ( (f) & PCF_SCAN_UNIT_MASK ) >> 4 )
212 #define PCF_SCAN_UNIT( f ) \
213           ( 1 << PCF_SCAN_UNIT_INDEX( f ) )
214 #define PCF_FORMAT_BITS( f )             \
215           ( (f) & ( PCF_GLYPH_PAD_MASK | \
216                     PCF_BYTE_MASK      | \
217                     PCF_BIT_MASK       | \
218                     PCF_SCAN_UNIT_MASK ) )
219 
220 #define PCF_SIZE_TO_INDEX( s )  ( (s) == 4 ? 2 : (s) == 2 ? 1 : 0 )
221 #define PCF_INDEX_TO_SIZE( b )  ( 1 << b )
222 
223 #define PCF_FORMAT( bit, byte, glyph, scan )          \
224           ( ( PCF_SIZE_TO_INDEX( scan )      << 4 ) | \
225             ( ( (bit)  == MSBFirst ? 1 : 0 ) << 3 ) | \
226             ( ( (byte) == MSBFirst ? 1 : 0 ) << 2 ) | \
227             ( PCF_SIZE_TO_INDEX( glyph )     << 0 ) )
228 
229 #define PCF_PROPERTIES        ( 1 << 0 )
230 #define PCF_ACCELERATORS      ( 1 << 1 )
231 #define PCF_METRICS           ( 1 << 2 )
232 #define PCF_BITMAPS           ( 1 << 3 )
233 #define PCF_INK_METRICS       ( 1 << 4 )
234 #define PCF_BDF_ENCODINGS     ( 1 << 5 )
235 #define PCF_SWIDTHS           ( 1 << 6 )
236 #define PCF_GLYPH_NAMES       ( 1 << 7 )
237 #define PCF_BDF_ACCELERATORS  ( 1 << 8 )
238 
239 #define GLYPHPADOPTIONS  4 /* I'm not sure about this */
240 
241   FT_LOCAL( FT_Error )
242   pcf_load_font( FT_Stream  stream,
243                  PCF_Face   face,
244                  FT_Long    face_index );
245 
246 FT_END_HEADER
247 
248 #endif /* PCF_H_ */
249 
250 
251 /* END */
252