]> git.saurik.com Git - wxWidgets.git/blob - src/freetype/otlayout/oltypes.h
fixed several resource leaks related to MDI menus
[wxWidgets.git] / src / freetype / otlayout / oltypes.h
1 #ifndef OLTYPES_H
2 #define OLTYPES_H
3
4 #include <ftobjs.h>
5 #include <tttypes.h>
6
7 /*************************************************************
8 *
9 * <Struct> OTL_Table
10 *
11 * <Description>
12 * The base table of most OpenType Layout sub-tables.
13 * Provides a simple way to scan a table for script,
14 * languages, features and lookups..
15 *
16 * <Fields>
17 * num_scripts :: number of scripts in table's script list
18 * script_tags :: array of tags for each table script
19 *
20 * max_languages :: max number of languages for any script in
21 * the table.
22 * num_languages :: number of languages available for current script
23 * language_tags :: tags of all languages available for current script.
24 *
25 * max_features :: total number of features in table
26 * feature_tags :: tags of all features for current script/language
27 * features :: selection flags for all features in current script/lang
28 *
29 * max_lookups :: total number of lookups in table
30 * lookups :: selection flags for all lookups for current
31 * feature list.
32 *
33 ****************************************************************/
34
35 typedef enum OTL_Type_
36 {
37 otl_type_none = 0,
38 otl_type_base,
39 otl_type_gdef,
40 otl_type_gpos,
41 otl_type_gsub,
42 otl_type_jstf
43
44 } OTL_Type;
45
46
47 typedef struct OTL_Table_
48 {
49 FT_Memory memory;
50
51 TT_Int num_scripts;
52 TT_Tag* script_tags;
53
54 TT_Int max_languages;
55 TT_Int num_languages;
56 TT_Tag* language_tags;
57
58 TT_Int max_features;
59 TT_Tag* feature_tags;
60 TT_Bool* features;
61
62 TT_Int max_lookups;
63 TT_Bool* lookups;
64
65 TT_Byte* scripts_table;
66 TT_Long scripts_len;
67
68 TT_Byte* features_table;
69 TT_Long* features_len;
70
71 TT_Byte* lookups_table;
72 TT_Byte* lookups_len;
73
74 TT_Byte* cur_script; /* current script */
75 TT_Byte* cur_language; /* current language */
76
77 TT_Byte* cur_base_values;
78 TT_Byte* cur_min_max;
79
80 OTL_Type otl_type;
81
82 } OTL_Table;
83
84
85 typedef struct OTL_BaseCoord_
86 {
87 TT_UShort format;
88 TT_Short coordinate;
89 TT_UShort ref_glyph;
90 TT_UShort ref_point;
91 TT_Byte* device;
92
93 } OTL_BaseCoord;
94
95
96 typedef struct OTL_ValueRecord_
97 {
98 TT_Vector placement;
99 TT_Vector advance;
100
101 TT_Byte* device_pla_x;
102 TT_Byte* device_pla_y;
103 TT_Byte* device_adv_x;
104 TT_Byte* device_adv_y;
105
106 } OTL_ValueRecord;
107
108
109 typedef struct OTL_Anchor_
110 {
111 TT_UInt format;
112 TT_Vector coord;
113 TT_UInt anchor_point;
114 TT_Byte* device_x;
115 TT_Byte* device_y;
116
117 } OTL_Anchor;
118
119 LOCAL_DEF
120 TT_Error OTL_Table_Init( OTL_Table* table,
121 FT_Memory memory );
122
123 LOCAL_DEF
124 TT_Error OTL_Table_Set_Scripts( OTL_Table* table,
125 TT_Byte* bytes,
126 TT_Long len,
127 OTL_Type otl_type );
128
129 LOCAL_DEF
130 TT_Error OTL_Table_Set_Features( OTL_Table* table,
131 TT_Byte* bytes,
132 TT_Long len );
133
134 LOCAL_DEF
135 TT_Error OTL_Table_Set_Lookups( OTL_Table* table,
136 TT_Byte* bytes,
137 TT_Long len );
138
139 LOCAL_DEF
140 void OTL_Table_Done( OTL_Table* table );
141
142
143
144 /*****************************************************
145 *
146 * Typical uses:
147 *
148 * - after OTL_Table_Set_Scripts have been called :
149 *
150 * table->script_tags contains the list of tags of all
151 * scripts defined for this table.
152 *
153 * table->num_scripts is the number of scripts
154 *
155 */
156
157 /********************************************************
158 *
159 * - after calling OTL_Table_Set_Features:
160 *
161 * table->max_features is the number of all features
162 * in the table
163 *
164 * table->feature_tags is the list of tags of all
165 * features in the table
166 *
167 * table->features[] is an array of boolean used to
168 * indicate which feature is active for a given script/language
169 * it is empty (zero-filled) by default.
170 *
171 */
172
173 /*******************************************************************
174 *
175 * - after calling OTL_Get_Languages_List(script_tag):
176 *
177 * table->num_languages is the number of language systems
178 * available for the script, including the default
179 * langsys if there is one
180 *
181 * table->language_tags contains the list of tags of all
182 * languages for the script. Note that the default langsys
183 * has tag "0" and is always placed first in "language_tags".
184 *
185 *
186 *
187 */
188 LOCAL_DEF
189 void OTL_Get_Languages_List( OTL_Table* table,
190 TT_ULong script_tag );
191
192
193 /*******************************************************************
194 *
195 * - after calling OTL_Get_Features_List(language_tag):
196 *
197 * table->features[] is an array of booleans used to indicate
198 * which features are active for the current script/language
199 *
200 * note that this function must be called after OTL_Get_Languages
201 * which remembers the last "script_tag" used..
202 *
203 * A client application can change the table->features[] array
204 * to add or remove features from the list.
205 *
206 *
207 *
208 */
209 LOCAL_DEF
210 void OTL_Get_Features_List( OTL_Table* table,
211 TT_ULong language_tag );
212
213 LOCAL_DEF
214 void OTL_Get_Baseline_Values( OTL_Table* table,
215 TT_ULong language_tag );
216
217 LOCAL_DEF
218 void OTL_Get_Justification( OTL_Table* table,
219 TT_ULong language_tag );
220
221 /*******************************************************************
222 *
223 * - after calling OTL_Get_Lookups_List():
224 *
225 * The function uses the table->features[] array of boolean
226 * to determine which lookups must be processed.
227 *
228 * It fills the table->lookups[] array accordingly. It is also
229 * an array of booleans (one for each lookup).
230 *
231 *
232 */
233
234 LOCAL_DEF
235 void OTL_Get_Lookups_List( OTL_Table* table );
236
237
238 /***************************************************************
239 *
240 * So the whole thing looks like:
241 *
242 *
243 * 1. A client specifies a given script and requests available
244 * language through OTL_Get_Languages_List()
245 *
246 * 2. It selects the language tag it needs, then calls
247 * OTL_Get_Features_List()
248 *
249 * 3. It updates the list of active features if it needs to
250 *
251 * 4. It calls OTL_Get_Lookups_List()
252 * It now has a list of active lookups in "table->lookups[]"
253 *
254 * 5. The lookups are processed according to the table's type..
255 *
256 */
257
258
259
260
261 LOCAL_DEF
262 TT_Long OTL_Get_Coverage_Index( TT_Byte* coverage,
263 TT_UInt glyph_id );
264
265 LOCAL_DEF
266 TT_UInt OTL_Get_Glyph_Class( TT_Byte* class_def,
267 TT_UInt glyph_id );
268
269 LOCAL_DEF
270 TT_Int OTL_Get_Device_Adjustment( TT_Byte* device,
271 TT_UInt size );
272
273 LOCAL_DEF
274 void OTL_Get_Base_Coordinate( TT_Byte* base_coord,
275 OTL_BaseCoord* coord );
276
277
278 LOCAL_DEF
279 TT_Int OTL_ValueRecord_Size( TT_UShort value_format );
280
281
282 LOCAL_DEF
283 void OTL_Get_ValueRecord( TT_Byte* value_record,
284 TT_UShort value_format,
285 TT_Byte* pos_table,
286 OTL_ValueRecord* record );
287
288
289 LOCAL_DEF
290 void OTL_Get_Anchor( TT_Byte* anchor_table,
291 OTL_Anchor* anchor );
292
293
294 LOCAL_DEF
295 void OTL_Get_Mark( TT_Byte* mark_array,
296 TT_UInt index,
297 TT_UShort* clazz,
298 OTL_Anchor* anchor );
299
300
301
302 #define OTL_Byte(p) (p++, p[-1])
303
304 #define OTL_UShort(p) (p+=2, ((TT_UShort)p[-2] << 8) | p[-1])
305
306 #define OTL_ULong(p) (p+=4, ((TT_ULong)p[-4] << 24) | \
307 ((TT_ULong)p[-3] << 16) | \
308 ((TT_ULong)p[-2] << 8 ) | p[-1] )
309
310 #endif /* OLTYPES_H */