OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ftdriver.h */ | 3 /* ftdriver.h */ |
4 /* */ | 4 /* */ |
5 /* FreeType font driver interface (specification). */ | 5 /* FreeType font driver interface (specification). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 1996-2003, 2006, 2008, 2011 by */ | 7 /* Copyright 1996-2003, 2006, 2008, 2011-2013 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 | 54 |
55 typedef FT_Error | 55 typedef FT_Error |
56 (*FT_Size_RequestFunc)( FT_Size size, | 56 (*FT_Size_RequestFunc)( FT_Size size, |
57 FT_Size_Request req ); | 57 FT_Size_Request req ); |
58 | 58 |
59 typedef FT_Error | 59 typedef FT_Error |
60 (*FT_Size_SelectFunc)( FT_Size size, | 60 (*FT_Size_SelectFunc)( FT_Size size, |
61 FT_ULong size_index ); | 61 FT_ULong size_index ); |
62 | 62 |
63 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS | |
64 | |
65 typedef FT_Error | |
66 (*FT_Size_ResetPointsFunc)( FT_Size size, | |
67 FT_F26Dot6 char_width, | |
68 FT_F26Dot6 char_height, | |
69 FT_UInt horz_resolution, | |
70 FT_UInt vert_resolution ); | |
71 | |
72 typedef FT_Error | |
73 (*FT_Size_ResetPixelsFunc)( FT_Size size, | |
74 FT_UInt pixel_width, | |
75 FT_UInt pixel_height ); | |
76 | |
77 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
78 | |
79 typedef FT_Error | 63 typedef FT_Error |
80 (*FT_Slot_LoadFunc)( FT_GlyphSlot slot, | 64 (*FT_Slot_LoadFunc)( FT_GlyphSlot slot, |
81 FT_Size size, | 65 FT_Size size, |
82 FT_UInt glyph_index, | 66 FT_UInt glyph_index, |
83 FT_Int32 load_flags ); | 67 FT_Int32 load_flags ); |
84 | 68 |
85 | 69 |
86 typedef FT_UInt | 70 typedef FT_UInt |
87 (*FT_CharMap_CharIndexFunc)( FT_CharMap charmap, | 71 (*FT_CharMap_CharIndexFunc)( FT_CharMap charmap, |
88 FT_Long charcode ); | 72 FT_Long charcode ); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 /* fixed size. It is used only if */ | 158 /* fixed size. It is used only if */ |
175 /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */ | 159 /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */ |
176 /* to 0 if the scaling done in the base layer */ | 160 /* to 0 if the scaling done in the base layer */ |
177 /* suffices. */ | 161 /* suffices. */ |
178 /* <Note> */ | 162 /* <Note> */ |
179 /* Most function pointers, with the exception of `load_glyph', can be */ | 163 /* Most function pointers, with the exception of `load_glyph', can be */ |
180 /* set to 0 to indicate a default behaviour. */ | 164 /* set to 0 to indicate a default behaviour. */ |
181 /* */ | 165 /* */ |
182 typedef struct FT_Driver_ClassRec_ | 166 typedef struct FT_Driver_ClassRec_ |
183 { | 167 { |
184 FT_Module_Class root; | 168 FT_Module_Class root; |
185 | 169 |
186 FT_Long face_object_size; | 170 FT_Long face_object_size; |
187 FT_Long size_object_size; | 171 FT_Long size_object_size; |
188 FT_Long slot_object_size; | 172 FT_Long slot_object_size; |
189 | 173 |
190 FT_Face_InitFunc init_face; | 174 FT_Face_InitFunc init_face; |
191 FT_Face_DoneFunc done_face; | 175 FT_Face_DoneFunc done_face; |
192 | 176 |
193 FT_Size_InitFunc init_size; | 177 FT_Size_InitFunc init_size; |
194 FT_Size_DoneFunc done_size; | 178 FT_Size_DoneFunc done_size; |
195 | 179 |
196 FT_Slot_InitFunc init_slot; | 180 FT_Slot_InitFunc init_slot; |
197 FT_Slot_DoneFunc done_slot; | 181 FT_Slot_DoneFunc done_slot; |
198 | 182 |
199 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS | 183 FT_Slot_LoadFunc load_glyph; |
200 | 184 |
201 FT_Size_ResetPointsFunc set_char_sizes; | 185 FT_Face_GetKerningFunc get_kerning; |
202 FT_Size_ResetPixelsFunc set_pixel_sizes; | 186 FT_Face_AttachFunc attach_file; |
203 | 187 FT_Face_GetAdvancesFunc get_advances; |
204 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
205 | |
206 FT_Slot_LoadFunc load_glyph; | |
207 | |
208 FT_Face_GetKerningFunc get_kerning; | |
209 FT_Face_AttachFunc attach_file; | |
210 FT_Face_GetAdvancesFunc get_advances; | |
211 | 188 |
212 /* since version 2.2 */ | 189 /* since version 2.2 */ |
213 FT_Size_RequestFunc request_size; | 190 FT_Size_RequestFunc request_size; |
214 FT_Size_SelectFunc select_size; | 191 FT_Size_SelectFunc select_size; |
215 | 192 |
216 } FT_Driver_ClassRec, *FT_Driver_Class; | 193 } FT_Driver_ClassRec, *FT_Driver_Class; |
217 | 194 |
218 | 195 |
219 /* | |
220 * The following functions are used as stubs for `set_char_sizes' and | |
221 * `set_pixel_sizes'; the code uses `request_size' and `select_size' | |
222 * functions instead. | |
223 * | |
224 * Implementation is in `src/base/ftobjs.c'. | |
225 */ | |
226 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS | |
227 | |
228 FT_BASE( FT_Error ) | |
229 ft_stub_set_char_sizes( FT_Size size, | |
230 FT_F26Dot6 width, | |
231 FT_F26Dot6 height, | |
232 FT_UInt horz_res, | |
233 FT_UInt vert_res ); | |
234 | |
235 FT_BASE( FT_Error ) | |
236 ft_stub_set_pixel_sizes( FT_Size size, | |
237 FT_UInt width, | |
238 FT_UInt height ); | |
239 | |
240 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
241 | |
242 /*************************************************************************/ | 196 /*************************************************************************/ |
243 /* */ | 197 /* */ |
244 /* <Macro> */ | 198 /* <Macro> */ |
245 /* FT_DECLARE_DRIVER */ | 199 /* FT_DECLARE_DRIVER */ |
246 /* */ | 200 /* */ |
247 /* <Description> */ | 201 /* <Description> */ |
248 /* Used to create a forward declaration of a */ | 202 /* Used to create a forward declaration of an FT_Driver_ClassRec */ |
249 /* FT_Driver_ClassRec stract instance. */ | 203 /* struct instance. */ |
250 /* */ | 204 /* */ |
251 /* <Macro> */ | 205 /* <Macro> */ |
252 /* FT_DEFINE_DRIVER */ | 206 /* FT_DEFINE_DRIVER */ |
253 /* */ | 207 /* */ |
254 /* <Description> */ | 208 /* <Description> */ |
255 /* Used to initialize an instance of FT_Driver_ClassRec struct. */ | 209 /* Used to initialize an instance of FT_Driver_ClassRec struct. */ |
256 /* */ | 210 /* */ |
257 /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */ | 211 /* When FT_CONFIG_OPTION_PIC is defined a `create' function has to be */ |
258 /* to called with a pointer where the allocated stracture is returned.*/ | 212 /* called with a pointer where the allocated structure is returned. */ |
259 /* And when it is no longer needed a Destroy function needs */ | 213 /* And when it is no longer needed a `destroy' function needs to be */ |
260 /* to be called to release that allocation. */ | 214 /* called to release that allocation. */ |
261 /* fcinit.c (ft_create_default_module_classes) already contains */ | |
262 /* a mechanism to call these functions for the default modules */ | |
263 /* described in ftmodule.h */ | |
264 /* */ | 215 /* */ |
265 /* Notice that the created Create and Destroy functions call */ | 216 /* `fcinit.c' (ft_create_default_module_classes) already contains a */ |
266 /* pic_init and pic_free function to allow you to manually allocate */ | 217 /* mechanism to call these functions for the default modules */ |
267 /* and initialize any additional global data, like module specific */ | 218 /* described in `ftmodule.h'. */ |
| 219 /* */ |
| 220 /* Notice that the created `create' and `destroy' functions call */ |
| 221 /* `pic_init' and `pic_free' to allow you to manually allocate and */ |
| 222 /* initialize any additional global data, like a module specific */ |
268 /* interface, and put them in the global pic container defined in */ | 223 /* interface, and put them in the global pic container defined in */ |
269 /* ftpic.h. if you don't need them just implement the functions as */ | 224 /* `ftpic.h'. If you don't need them just implement the functions as */ |
270 /* empty to resolve the link error. Also the pic_init and pic_free */ | 225 /* empty to resolve the link error. Also the `pic_init' and */ |
271 /* functions should be declared in pic.h, to be referred by driver */ | 226 /* `pic_free' functions should be declared in `pic.h', to be referred */ |
272 /* definition calling FT_DEFINE_DRIVER() in following. */ | 227 /* by driver definition calling `FT_DEFINE_DRIVER' in following. */ |
273 /* */ | 228 /* */ |
274 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ | 229 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ |
275 /* allocated in the global scope (or the scope where the macro */ | 230 /* allocated in the global scope (or the scope where the macro is */ |
276 /* is used). */ | 231 /* used). */ |
277 /* */ | 232 /* */ |
278 #ifndef FT_CONFIG_OPTION_PIC | 233 #ifndef FT_CONFIG_OPTION_PIC |
279 | 234 |
280 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS | 235 #define FT_DECLARE_DRIVER( class_ ) \ |
281 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \ | |
282 a_, b_, | |
283 #else | |
284 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) | |
285 #endif | |
286 | |
287 #define FT_DECLARE_DRIVER(class_) \ | |
288 FT_CALLBACK_TABLE \ | 236 FT_CALLBACK_TABLE \ |
289 const FT_Driver_ClassRec class_; | 237 const FT_Driver_ClassRec class_; |
290 | 238 |
291 #define FT_DEFINE_DRIVER(class_, \ | 239 #define FT_DEFINE_DRIVER( \ |
292 flags_, size_, name_, version_, requires_, \ | 240 class_, \ |
293 interface_, init_, done_, get_interface_, \ | 241 flags_, \ |
294 face_object_size_, size_object_size_, \ | 242 size_, \ |
295 slot_object_size_, init_face_, done_face_, \ | 243 name_, \ |
296 init_size_, done_size_, init_slot_, done_slot_, \ | 244 version_, \ |
297 old_set_char_sizes_, old_set_pixel_sizes_, \ | 245 requires_, \ |
298 load_glyph_, get_kerning_, attach_file_, \ | 246 interface_, \ |
299 get_advances_, request_size_, select_size_ ) \ | 247 init_, \ |
300 FT_CALLBACK_TABLE_DEF \ | 248 done_, \ |
301 const FT_Driver_ClassRec class_ = \ | 249 get_interface_, \ |
302 { \ | 250 face_object_size_, \ |
303 FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \ | 251 size_object_size_, \ |
304 init_,done_,get_interface_) \ | 252 slot_object_size_, \ |
305 \ | 253 init_face_, \ |
306 face_object_size_, \ | 254 done_face_, \ |
307 size_object_size_, \ | 255 init_size_, \ |
308 slot_object_size_, \ | 256 done_size_, \ |
309 \ | 257 init_slot_, \ |
310 init_face_, \ | 258 done_slot_, \ |
311 done_face_, \ | 259 load_glyph_, \ |
312 \ | 260 get_kerning_, \ |
313 init_size_, \ | 261 attach_file_, \ |
314 done_size_, \ | 262 get_advances_, \ |
315 \ | 263 request_size_, \ |
316 init_slot_, \ | 264 select_size_ ) \ |
317 done_slot_, \ | 265 FT_CALLBACK_TABLE_DEF \ |
318 \ | 266 const FT_Driver_ClassRec class_ = \ |
319 FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \ | 267 { \ |
320 \ | 268 FT_DEFINE_ROOT_MODULE( flags_, \ |
321 load_glyph_, \ | 269 size_, \ |
322 \ | 270 name_, \ |
323 get_kerning_, \ | 271 version_, \ |
324 attach_file_, \ | 272 requires_, \ |
325 get_advances_, \ | 273 interface_, \ |
326 \ | 274 init_, \ |
327 request_size_, \ | 275 done_, \ |
328 select_size_ \ | 276 get_interface_ ) \ |
| 277 \ |
| 278 face_object_size_, \ |
| 279 size_object_size_, \ |
| 280 slot_object_size_, \ |
| 281 \ |
| 282 init_face_, \ |
| 283 done_face_, \ |
| 284 \ |
| 285 init_size_, \ |
| 286 done_size_, \ |
| 287 \ |
| 288 init_slot_, \ |
| 289 done_slot_, \ |
| 290 \ |
| 291 load_glyph_, \ |
| 292 \ |
| 293 get_kerning_, \ |
| 294 attach_file_, \ |
| 295 get_advances_, \ |
| 296 \ |
| 297 request_size_, \ |
| 298 select_size_ \ |
329 }; | 299 }; |
330 | 300 |
331 #else /* FT_CONFIG_OPTION_PIC */ | 301 #else /* FT_CONFIG_OPTION_PIC */ |
332 | 302 |
333 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS | 303 #define FT_DECLARE_DRIVER( class_ ) FT_DECLARE_MODULE( class_ ) |
334 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \ | |
335 clazz->set_char_sizes = a_; \ | |
336 clazz->set_pixel_sizes = b_; | |
337 #else | |
338 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) | |
339 #endif | |
340 | 304 |
341 #define FT_DECLARE_DRIVER(class_) FT_DECLARE_MODULE(class_) | 305 #define FT_DEFINE_DRIVER( \ |
342 | 306 class_, \ |
343 #define FT_DEFINE_DRIVER(class_, \ | 307 flags_, \ |
344 flags_, size_, name_, version_, requires_, \ | 308 size_, \ |
345 interface_, init_, done_, get_interface_, \ | 309 name_, \ |
346 face_object_size_, size_object_size_, \ | 310 version_, \ |
347 slot_object_size_, init_face_, done_face_, \ | 311 requires_, \ |
348 init_size_, done_size_, init_slot_, done_slot_, \ | 312 interface_, \ |
349 old_set_char_sizes_, old_set_pixel_sizes_, \ | 313 init_, \ |
350 load_glyph_, get_kerning_, attach_file_, \ | 314 done_, \ |
351 get_advances_, request_size_, select_size_ ) \ | 315 get_interface_, \ |
352 \ | 316 face_object_size_, \ |
353 void \ | 317 size_object_size_, \ |
354 FT_Destroy_Class_##class_( FT_Library library, \ | 318 slot_object_size_, \ |
355 FT_Module_Class* clazz ) \ | 319 init_face_, \ |
356 { \ | 320 done_face_, \ |
357 FT_Memory memory = library->memory; \ | 321 init_size_, \ |
358 FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \ | 322 done_size_, \ |
359 class_##_pic_free( library ); \ | 323 init_slot_, \ |
360 if ( dclazz ) \ | 324 done_slot_, \ |
361 FT_FREE( dclazz ); \ | 325 load_glyph_, \ |
362 } \ | 326 get_kerning_, \ |
363 \ | 327 attach_file_, \ |
364 FT_Error \ | 328 get_advances_, \ |
365 FT_Create_Class_##class_( FT_Library library, \ | 329 request_size_, \ |
366 FT_Module_Class** output_class ) \ | 330 select_size_ ) \ |
367 { \ | 331 void \ |
368 FT_Driver_Class clazz; \ | 332 FT_Destroy_Class_ ## class_( FT_Library library, \ |
369 FT_Error error; \ | 333 FT_Module_Class* clazz ) \ |
370 FT_Memory memory = library->memory; \ | 334 { \ |
371 \ | 335 FT_Memory memory = library->memory; \ |
372 if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \ | 336 FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \ |
373 return error; \ | 337 \ |
374 \ | 338 \ |
375 error = class_##_pic_init( library ); \ | 339 class_ ## _pic_free( library ); \ |
376 if(error) \ | 340 if ( dclazz ) \ |
377 { \ | 341 FT_FREE( dclazz ); \ |
378 FT_FREE( clazz ); \ | 342 } \ |
379 return error; \ | 343 \ |
380 } \ | 344 \ |
381 \ | 345 FT_Error \ |
382 FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \ | 346 FT_Create_Class_ ## class_( FT_Library library, \ |
383 init_,done_,get_interface_) \ | 347 FT_Module_Class** output_class ) \ |
384 \ | 348 { \ |
385 clazz->face_object_size = face_object_size_; \ | 349 FT_Driver_Class clazz = NULL; \ |
386 clazz->size_object_size = size_object_size_; \ | 350 FT_Error error; \ |
387 clazz->slot_object_size = slot_object_size_; \ | 351 FT_Memory memory = library->memory; \ |
388 \ | 352 \ |
389 clazz->init_face = init_face_; \ | 353 \ |
390 clazz->done_face = done_face_; \ | 354 if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ |
391 \ | 355 return error; \ |
392 clazz->init_size = init_size_; \ | 356 \ |
393 clazz->done_size = done_size_; \ | 357 error = class_ ## _pic_init( library ); \ |
394 \ | 358 if ( error ) \ |
395 clazz->init_slot = init_slot_; \ | 359 { \ |
396 clazz->done_slot = done_slot_; \ | 360 FT_FREE( clazz ); \ |
397 \ | 361 return error; \ |
398 FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \ | 362 } \ |
399 \ | 363 \ |
400 clazz->load_glyph = load_glyph_; \ | 364 FT_DEFINE_ROOT_MODULE( flags_, \ |
401 \ | 365 size_, \ |
402 clazz->get_kerning = get_kerning_; \ | 366 name_, \ |
403 clazz->attach_file = attach_file_; \ | 367 version_, \ |
404 clazz->get_advances = get_advances_; \ | 368 requires_, \ |
405 \ | 369 interface_, \ |
406 clazz->request_size = request_size_; \ | 370 init_, \ |
407 clazz->select_size = select_size_; \ | 371 done_, \ |
408 \ | 372 get_interface_ ) \ |
409 *output_class = (FT_Module_Class*)clazz; \ | 373 \ |
410 return FT_Err_Ok; \ | 374 clazz->face_object_size = face_object_size_; \ |
| 375 clazz->size_object_size = size_object_size_; \ |
| 376 clazz->slot_object_size = slot_object_size_; \ |
| 377 \ |
| 378 clazz->init_face = init_face_; \ |
| 379 clazz->done_face = done_face_; \ |
| 380 \ |
| 381 clazz->init_size = init_size_; \ |
| 382 clazz->done_size = done_size_; \ |
| 383 \ |
| 384 clazz->init_slot = init_slot_; \ |
| 385 clazz->done_slot = done_slot_; \ |
| 386 \ |
| 387 clazz->load_glyph = load_glyph_; \ |
| 388 \ |
| 389 clazz->get_kerning = get_kerning_; \ |
| 390 clazz->attach_file = attach_file_; \ |
| 391 clazz->get_advances = get_advances_; \ |
| 392 \ |
| 393 clazz->request_size = request_size_; \ |
| 394 clazz->select_size = select_size_; \ |
| 395 \ |
| 396 *output_class = (FT_Module_Class*)clazz; \ |
| 397 \ |
| 398 return FT_Err_Ok; \ |
411 } | 399 } |
412 | 400 |
413 | 401 |
414 #endif /* FT_CONFIG_OPTION_PIC */ | 402 #endif /* FT_CONFIG_OPTION_PIC */ |
415 | 403 |
416 FT_END_HEADER | 404 FT_END_HEADER |
417 | 405 |
418 #endif /* __FTDRIVER_H__ */ | 406 #endif /* __FTDRIVER_H__ */ |
419 | 407 |
420 | 408 |
421 /* END */ | 409 /* END */ |
OLD | NEW |