vrshoot
diff libs/ft2static/freetype/internal/ftdriver.h @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/ft2static/freetype/internal/ftdriver.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,422 @@ 1.4 +/***************************************************************************/ 1.5 +/* */ 1.6 +/* ftdriver.h */ 1.7 +/* */ 1.8 +/* FreeType font driver interface (specification). */ 1.9 +/* */ 1.10 +/* Copyright 1996-2001, 2002, 2003, 2006, 2008 by */ 1.11 +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ 1.12 +/* */ 1.13 +/* This file is part of the FreeType project, and may only be used, */ 1.14 +/* modified, and distributed under the terms of the FreeType project */ 1.15 +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 1.16 +/* this file you indicate that you have read the license and */ 1.17 +/* understand and accept it fully. */ 1.18 +/* */ 1.19 +/***************************************************************************/ 1.20 + 1.21 + 1.22 +#ifndef __FTDRIVER_H__ 1.23 +#define __FTDRIVER_H__ 1.24 + 1.25 + 1.26 +#include <ft2build.h> 1.27 +#include FT_MODULE_H 1.28 + 1.29 + 1.30 +FT_BEGIN_HEADER 1.31 + 1.32 + 1.33 + typedef FT_Error 1.34 + (*FT_Face_InitFunc)( FT_Stream stream, 1.35 + FT_Face face, 1.36 + FT_Int typeface_index, 1.37 + FT_Int num_params, 1.38 + FT_Parameter* parameters ); 1.39 + 1.40 + typedef void 1.41 + (*FT_Face_DoneFunc)( FT_Face face ); 1.42 + 1.43 + 1.44 + typedef FT_Error 1.45 + (*FT_Size_InitFunc)( FT_Size size ); 1.46 + 1.47 + typedef void 1.48 + (*FT_Size_DoneFunc)( FT_Size size ); 1.49 + 1.50 + 1.51 + typedef FT_Error 1.52 + (*FT_Slot_InitFunc)( FT_GlyphSlot slot ); 1.53 + 1.54 + typedef void 1.55 + (*FT_Slot_DoneFunc)( FT_GlyphSlot slot ); 1.56 + 1.57 + 1.58 + typedef FT_Error 1.59 + (*FT_Size_RequestFunc)( FT_Size size, 1.60 + FT_Size_Request req ); 1.61 + 1.62 + typedef FT_Error 1.63 + (*FT_Size_SelectFunc)( FT_Size size, 1.64 + FT_ULong size_index ); 1.65 + 1.66 +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS 1.67 + 1.68 + typedef FT_Error 1.69 + (*FT_Size_ResetPointsFunc)( FT_Size size, 1.70 + FT_F26Dot6 char_width, 1.71 + FT_F26Dot6 char_height, 1.72 + FT_UInt horz_resolution, 1.73 + FT_UInt vert_resolution ); 1.74 + 1.75 + typedef FT_Error 1.76 + (*FT_Size_ResetPixelsFunc)( FT_Size size, 1.77 + FT_UInt pixel_width, 1.78 + FT_UInt pixel_height ); 1.79 + 1.80 +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ 1.81 + 1.82 + typedef FT_Error 1.83 + (*FT_Slot_LoadFunc)( FT_GlyphSlot slot, 1.84 + FT_Size size, 1.85 + FT_UInt glyph_index, 1.86 + FT_Int32 load_flags ); 1.87 + 1.88 + 1.89 + typedef FT_UInt 1.90 + (*FT_CharMap_CharIndexFunc)( FT_CharMap charmap, 1.91 + FT_Long charcode ); 1.92 + 1.93 + typedef FT_Long 1.94 + (*FT_CharMap_CharNextFunc)( FT_CharMap charmap, 1.95 + FT_Long charcode ); 1.96 + 1.97 + 1.98 + typedef FT_Error 1.99 + (*FT_Face_GetKerningFunc)( FT_Face face, 1.100 + FT_UInt left_glyph, 1.101 + FT_UInt right_glyph, 1.102 + FT_Vector* kerning ); 1.103 + 1.104 + 1.105 + typedef FT_Error 1.106 + (*FT_Face_AttachFunc)( FT_Face face, 1.107 + FT_Stream stream ); 1.108 + 1.109 + 1.110 + typedef FT_Error 1.111 + (*FT_Face_GetAdvancesFunc)( FT_Face face, 1.112 + FT_UInt first, 1.113 + FT_UInt count, 1.114 + FT_Int32 flags, 1.115 + FT_Fixed* advances ); 1.116 + 1.117 + 1.118 + /*************************************************************************/ 1.119 + /* */ 1.120 + /* <Struct> */ 1.121 + /* FT_Driver_ClassRec */ 1.122 + /* */ 1.123 + /* <Description> */ 1.124 + /* The font driver class. This structure mostly contains pointers to */ 1.125 + /* driver methods. */ 1.126 + /* */ 1.127 + /* <Fields> */ 1.128 + /* root :: The parent module. */ 1.129 + /* */ 1.130 + /* face_object_size :: The size of a face object in bytes. */ 1.131 + /* */ 1.132 + /* size_object_size :: The size of a size object in bytes. */ 1.133 + /* */ 1.134 + /* slot_object_size :: The size of a glyph object in bytes. */ 1.135 + /* */ 1.136 + /* init_face :: The format-specific face constructor. */ 1.137 + /* */ 1.138 + /* done_face :: The format-specific face destructor. */ 1.139 + /* */ 1.140 + /* init_size :: The format-specific size constructor. */ 1.141 + /* */ 1.142 + /* done_size :: The format-specific size destructor. */ 1.143 + /* */ 1.144 + /* init_slot :: The format-specific slot constructor. */ 1.145 + /* */ 1.146 + /* done_slot :: The format-specific slot destructor. */ 1.147 + /* */ 1.148 + /* */ 1.149 + /* load_glyph :: A function handle to load a glyph to a slot. */ 1.150 + /* This field is mandatory! */ 1.151 + /* */ 1.152 + /* get_kerning :: A function handle to return the unscaled */ 1.153 + /* kerning for a given pair of glyphs. Can be */ 1.154 + /* set to 0 if the format doesn't support */ 1.155 + /* kerning. */ 1.156 + /* */ 1.157 + /* attach_file :: This function handle is used to read */ 1.158 + /* additional data for a face from another */ 1.159 + /* file/stream. For example, this can be used to */ 1.160 + /* add data from AFM or PFM files on a Type 1 */ 1.161 + /* face, or a CIDMap on a CID-keyed face. */ 1.162 + /* */ 1.163 + /* get_advances :: A function handle used to return advance */ 1.164 + /* widths of `count' glyphs (in font units), */ 1.165 + /* starting at `first'. The `vertical' flag must */ 1.166 + /* be set to get vertical advance heights. The */ 1.167 + /* `advances' buffer is caller-allocated. */ 1.168 + /* Currently not implemented. The idea of this */ 1.169 + /* function is to be able to perform */ 1.170 + /* device-independent text layout without loading */ 1.171 + /* a single glyph image. */ 1.172 + /* */ 1.173 + /* request_size :: A handle to a function used to request the new */ 1.174 + /* character size. Can be set to 0 if the */ 1.175 + /* scaling done in the base layer suffices. */ 1.176 + /* */ 1.177 + /* select_size :: A handle to a function used to select a new */ 1.178 + /* fixed size. It is used only if */ 1.179 + /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */ 1.180 + /* to 0 if the scaling done in the base layer */ 1.181 + /* suffices. */ 1.182 + /* <Note> */ 1.183 + /* Most function pointers, with the exception of `load_glyph', can be */ 1.184 + /* set to 0 to indicate a default behaviour. */ 1.185 + /* */ 1.186 + typedef struct FT_Driver_ClassRec_ 1.187 + { 1.188 + FT_Module_Class root; 1.189 + 1.190 + FT_Long face_object_size; 1.191 + FT_Long size_object_size; 1.192 + FT_Long slot_object_size; 1.193 + 1.194 + FT_Face_InitFunc init_face; 1.195 + FT_Face_DoneFunc done_face; 1.196 + 1.197 + FT_Size_InitFunc init_size; 1.198 + FT_Size_DoneFunc done_size; 1.199 + 1.200 + FT_Slot_InitFunc init_slot; 1.201 + FT_Slot_DoneFunc done_slot; 1.202 + 1.203 +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS 1.204 + 1.205 + FT_Size_ResetPointsFunc set_char_sizes; 1.206 + FT_Size_ResetPixelsFunc set_pixel_sizes; 1.207 + 1.208 +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ 1.209 + 1.210 + FT_Slot_LoadFunc load_glyph; 1.211 + 1.212 + FT_Face_GetKerningFunc get_kerning; 1.213 + FT_Face_AttachFunc attach_file; 1.214 + FT_Face_GetAdvancesFunc get_advances; 1.215 + 1.216 + /* since version 2.2 */ 1.217 + FT_Size_RequestFunc request_size; 1.218 + FT_Size_SelectFunc select_size; 1.219 + 1.220 + } FT_Driver_ClassRec, *FT_Driver_Class; 1.221 + 1.222 + 1.223 + /* 1.224 + * The following functions are used as stubs for `set_char_sizes' and 1.225 + * `set_pixel_sizes'; the code uses `request_size' and `select_size' 1.226 + * functions instead. 1.227 + * 1.228 + * Implementation is in `src/base/ftobjs.c'. 1.229 + */ 1.230 +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS 1.231 + 1.232 + FT_BASE( FT_Error ) 1.233 + ft_stub_set_char_sizes( FT_Size size, 1.234 + FT_F26Dot6 width, 1.235 + FT_F26Dot6 height, 1.236 + FT_UInt horz_res, 1.237 + FT_UInt vert_res ); 1.238 + 1.239 + FT_BASE( FT_Error ) 1.240 + ft_stub_set_pixel_sizes( FT_Size size, 1.241 + FT_UInt width, 1.242 + FT_UInt height ); 1.243 + 1.244 +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ 1.245 + 1.246 + /*************************************************************************/ 1.247 + /* */ 1.248 + /* <Macro> */ 1.249 + /* FT_DECLARE_DRIVER */ 1.250 + /* */ 1.251 + /* <Description> */ 1.252 + /* Used to create a forward declaration of a */ 1.253 + /* FT_Driver_ClassRec stract instance. */ 1.254 + /* */ 1.255 + /* <Macro> */ 1.256 + /* FT_DEFINE_DRIVER */ 1.257 + /* */ 1.258 + /* <Description> */ 1.259 + /* Used to initialize an instance of FT_Driver_ClassRec struct. */ 1.260 + /* */ 1.261 + /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */ 1.262 + /* to called with a pointer where the allocated stracture is returned.*/ 1.263 + /* And when it is no longer needed a Destroy function needs */ 1.264 + /* to be called to release that allocation. */ 1.265 + /* fcinit.c (ft_create_default_module_classes) already contains */ 1.266 + /* a mechanism to call these functions for the default modules */ 1.267 + /* described in ftmodule.h */ 1.268 + /* */ 1.269 + /* Notice that the created Create and Destroy functions call */ 1.270 + /* pic_init and pic_free function to allow you to manually allocate */ 1.271 + /* and initialize any additional global data, like module specific */ 1.272 + /* interface, and put them in the global pic container defined in */ 1.273 + /* ftpic.h. if you don't need them just implement the functions as */ 1.274 + /* empty to resolve the link error. */ 1.275 + /* */ 1.276 + /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ 1.277 + /* allocated in the global scope (or the scope where the macro */ 1.278 + /* is used). */ 1.279 + /* */ 1.280 +#ifndef FT_CONFIG_OPTION_PIC 1.281 + 1.282 +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS 1.283 +#define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \ 1.284 + a_, b_, 1.285 +#else 1.286 + #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) 1.287 +#endif 1.288 + 1.289 +#define FT_DECLARE_DRIVER(class_) \ 1.290 + FT_CALLBACK_TABLE \ 1.291 + const FT_Driver_ClassRec class_; 1.292 + 1.293 +#define FT_DEFINE_DRIVER(class_, \ 1.294 + flags_, size_, name_, version_, requires_, \ 1.295 + interface_, init_, done_, get_interface_, \ 1.296 + face_object_size_, size_object_size_, \ 1.297 + slot_object_size_, init_face_, done_face_, \ 1.298 + init_size_, done_size_, init_slot_, done_slot_, \ 1.299 + old_set_char_sizes_, old_set_pixel_sizes_, \ 1.300 + load_glyph_, get_kerning_, attach_file_, \ 1.301 + get_advances_, request_size_, select_size_ ) \ 1.302 + FT_CALLBACK_TABLE_DEF \ 1.303 + const FT_Driver_ClassRec class_ = \ 1.304 + { \ 1.305 + FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \ 1.306 + init_,done_,get_interface_) \ 1.307 + \ 1.308 + face_object_size_, \ 1.309 + size_object_size_, \ 1.310 + slot_object_size_, \ 1.311 + \ 1.312 + init_face_, \ 1.313 + done_face_, \ 1.314 + \ 1.315 + init_size_, \ 1.316 + done_size_, \ 1.317 + \ 1.318 + init_slot_, \ 1.319 + done_slot_, \ 1.320 + \ 1.321 + FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \ 1.322 + \ 1.323 + load_glyph_, \ 1.324 + \ 1.325 + get_kerning_, \ 1.326 + attach_file_, \ 1.327 + get_advances_, \ 1.328 + \ 1.329 + request_size_, \ 1.330 + select_size_ \ 1.331 + }; 1.332 + 1.333 +#else /* FT_CONFIG_OPTION_PIC */ 1.334 + 1.335 +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS 1.336 +#define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \ 1.337 + clazz->set_char_sizes = a_; \ 1.338 + clazz->set_pixel_sizes = b_; 1.339 +#else 1.340 + #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) 1.341 +#endif 1.342 + 1.343 +#define FT_DECLARE_DRIVER(class_) FT_DECLARE_MODULE(class_) 1.344 + 1.345 +#define FT_DEFINE_DRIVER(class_, \ 1.346 + flags_, size_, name_, version_, requires_, \ 1.347 + interface_, init_, done_, get_interface_, \ 1.348 + face_object_size_, size_object_size_, \ 1.349 + slot_object_size_, init_face_, done_face_, \ 1.350 + init_size_, done_size_, init_slot_, done_slot_, \ 1.351 + old_set_char_sizes_, old_set_pixel_sizes_, \ 1.352 + load_glyph_, get_kerning_, attach_file_, \ 1.353 + get_advances_, request_size_, select_size_ ) \ 1.354 + void class_##_pic_free( FT_Library library ); \ 1.355 + FT_Error class_##_pic_init( FT_Library library ); \ 1.356 + \ 1.357 + void \ 1.358 + FT_Destroy_Class_##class_( FT_Library library, \ 1.359 + FT_Module_Class* clazz ) \ 1.360 + { \ 1.361 + FT_Memory memory = library->memory; \ 1.362 + FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \ 1.363 + class_##_pic_free( library ); \ 1.364 + if ( dclazz ) \ 1.365 + FT_FREE( dclazz ); \ 1.366 + } \ 1.367 + \ 1.368 + FT_Error \ 1.369 + FT_Create_Class_##class_( FT_Library library, \ 1.370 + FT_Module_Class** output_class ) \ 1.371 + { \ 1.372 + FT_Driver_Class clazz; \ 1.373 + FT_Error error; \ 1.374 + FT_Memory memory = library->memory; \ 1.375 + \ 1.376 + if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \ 1.377 + return error; \ 1.378 + \ 1.379 + error = class_##_pic_init( library ); \ 1.380 + if(error) \ 1.381 + { \ 1.382 + FT_FREE( clazz ); \ 1.383 + return error; \ 1.384 + } \ 1.385 + \ 1.386 + FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \ 1.387 + init_,done_,get_interface_) \ 1.388 + \ 1.389 + clazz->face_object_size = face_object_size_; \ 1.390 + clazz->size_object_size = size_object_size_; \ 1.391 + clazz->slot_object_size = slot_object_size_; \ 1.392 + \ 1.393 + clazz->init_face = init_face_; \ 1.394 + clazz->done_face = done_face_; \ 1.395 + \ 1.396 + clazz->init_size = init_size_; \ 1.397 + clazz->done_size = done_size_; \ 1.398 + \ 1.399 + clazz->init_slot = init_slot_; \ 1.400 + clazz->done_slot = done_slot_; \ 1.401 + \ 1.402 + FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \ 1.403 + \ 1.404 + clazz->load_glyph = load_glyph_; \ 1.405 + \ 1.406 + clazz->get_kerning = get_kerning_; \ 1.407 + clazz->attach_file = attach_file_; \ 1.408 + clazz->get_advances = get_advances_; \ 1.409 + \ 1.410 + clazz->request_size = request_size_; \ 1.411 + clazz->select_size = select_size_; \ 1.412 + \ 1.413 + *output_class = (FT_Module_Class*)clazz; \ 1.414 + return FT_Err_Ok; \ 1.415 + } 1.416 + 1.417 + 1.418 +#endif /* FT_CONFIG_OPTION_PIC */ 1.419 + 1.420 +FT_END_HEADER 1.421 + 1.422 +#endif /* __FTDRIVER_H__ */ 1.423 + 1.424 + 1.425 +/* END */