summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorOran Agra <oran@monfort.co.il>2009-04-05 17:59:26 +0300
committerOran Agra <oran@monfort.co.il>2009-04-05 17:59:26 +0300
commit636c294befc6df661a6496af49b8f7341fb2717f (patch)
tree10f1fb05c52a9723776baf2e077134d2cb175cdf /include
parent2589e5fd94a24cc175fa7690cb3dbf16c7844229 (diff)
downloadfreetype2-636c294befc6df661a6496af49b8f7341fb2717f.tar.gz
Position Independent Code (PIC) support and infrastructure in base.
* include/freetype/config/ftoption.h add FT_CONFIG_OPTION_PIC * include/freetype/internal/ftobjs.h Add pic_container member to FT_LibraryRec. Add macros to declare and init instances of FT_CMap_ClassRec. Add macros to init instances of FT_Outline_Funcs and FT_Raster_Funcs. Add macros to declare, allocate and initialize modules (FT_Module_Class). Add macros to declare, allocate and initialize renderers (FT_Renderer_Class). Add macro to init instances of FT_Glyph_Class. Add macros to declare, allocate and initialize drivers (FT_Driver_ClassRec). * include/freetype/internal/ftpic.h new file to declare the FT_PIC_Container struct and the functions to allocate and detroy it. * include/freetype/internal/ftserv.h add macros to allocate and destory arrays of FT_ServiceDescRec. * include/freetype/internal/internal.h define macro to include ftpic.h. New Files: * src/base/ftpic.c implement functions to allocate and destory the global pic_container. * src/base/basepic.h declare struct to hold PIC globals for base and macros to access them. * src/base/basepic.c implement functions to allocate, destroy and initialize PIC globals for base. * src/base/ftinit.c when FT_CONFIG_OPTION_PIC is defined implement functions that allocate and destroy ft_default_modules according to FT_CONFIG_MODULES_H in the pic_container instead of the global scope and use macro from basepic.h to access it. * src/base/ftobjs.c add calls to the functions that allocate and destroy the global pic_container when the library is created and destroyed. * src/base/jamfile add new files to FT2_MULTI build: ftpic.c and basepic.c. * src/base/ftbase.c add new files to build: ftpic.c and basepic.c. * src/base/ftglyph.c when FT_CONFIG_OPTION_PIC is defined ft_bitmap_glyph_class and ft_outline_glyph_class will be allocated in the pic_container instead of the global scope and use macros from basepic.h to access them. * src/base/ftbbox.c allocate bbox_interface stract on the stack instead of the global scope when FT_CONFIG_OPTION_PIC is defined. * src/base/ftstroke.c access ft_outline_glyph_class allocated in ftglyph.c via macros from basepic.h
Diffstat (limited to 'include')
-rw-r--r--include/freetype/config/ftoption.h14
-rw-r--r--include/freetype/internal/ftdriver.h173
-rw-r--r--include/freetype/internal/ftobjs.h526
-rw-r--r--include/freetype/internal/ftpic.h67
-rw-r--r--include/freetype/internal/ftserv.h292
-rw-r--r--include/freetype/internal/internal.h1
6 files changed, 1073 insertions, 0 deletions
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index b5bc76913..759b3a3b3 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -396,6 +396,20 @@ FT_BEGIN_HEADER
#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
+ /*************************************************************************/
+ /* */
+ /* Position Independent Code */
+ /* */
+ /* If this macro is set (which is _not_ the default), FreeType2 will */
+ /* avoid creating constants that require address fixups. Instead the */
+ /* constants will be moved into a struct and additional intialization */
+ /* code will be used. */
+ /* */
+ /* Setting this macro is needed for systems that prohibit address */
+ /* fixups, such as BREW. */
+ /* */
+/* #define FT_CONFIG_OPTION_PIC */
+
/*************************************************************************/
/*************************************************************************/
diff --git a/include/freetype/internal/ftdriver.h b/include/freetype/internal/ftdriver.h
index 854abad08..1d06997bd 100644
--- a/include/freetype/internal/ftdriver.h
+++ b/include/freetype/internal/ftdriver.h
@@ -240,6 +240,179 @@ FT_BEGIN_HEADER
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
+ /*************************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_DECLARE_DRIVER */
+ /* */
+ /* <Description> */
+ /* Used to create a forward declaration of a */
+ /* FT_Driver_ClassRec stract instance. */
+ /* */
+ /* <Macro> */
+ /* FT_DEFINE_DRIVER */
+ /* */
+ /* <Description> */
+ /* Used to initialize an instance of FT_Driver_ClassRec struct. */
+ /* */
+ /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
+ /* to called with a pointer where the allocated stracture is returned.*/
+ /* And when it is no longer needed a Destroy function needs */
+ /* to be called to release that allocation. */
+ /* fcinit.c (ft_create_default_module_classes) already contains */
+ /* a mechanism to call these functions for the default modules */
+ /* described in ftmodule.h */
+ /* */
+ /* Notice that the created Create and Destroy functions call */
+ /* pic_init and pic_free function to allow you to manually allocate */
+ /* and initialize any additional global data, like module specific */
+ /* interface, and put them in the global pic container defined in */
+ /* ftpic.h. if you don't need them just implement the functions as */
+ /* empty to resolve the link error. */
+ /* */
+ /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
+ /* allocated in the global scope (or the scope where the macro */
+ /* is used). */
+ /* */
+#ifndef FT_CONFIG_OPTION_PIC
+
+#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
+#define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \
+ a_, b_,
+#else
+ #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_)
+#endif
+
+#define FT_DECLARE_DRIVER(class_) \
+ FT_CALLBACK_TABLE \
+ const FT_Driver_ClassRec class_;
+
+#define FT_DEFINE_DRIVER(class_, \
+ flags_, size_, name_, version_, requires_, \
+ interface_, init_, done_, get_interface_, \
+ face_object_size_, size_object_size_, \
+ slot_object_size_, init_face_, done_face_, \
+ init_size_, done_size_, init_slot_, done_slot_, \
+ old_set_char_sizes_, old_set_pixel_sizes_, \
+ load_glyph_, get_kerning_, attach_file_, \
+ get_advances_, request_size_, select_size_ ) \
+ FT_CALLBACK_TABLE_DEF \
+ const FT_Driver_ClassRec class_ = \
+ { \
+ FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \
+ init_,done_,get_interface_) \
+ \
+ face_object_size_, \
+ size_object_size_, \
+ slot_object_size_, \
+ \
+ init_face_, \
+ done_face_, \
+ \
+ init_size_, \
+ done_size_, \
+ \
+ init_slot_, \
+ done_slot_, \
+ \
+ FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \
+ \
+ load_glyph_, \
+ \
+ get_kerning_, \
+ attach_file_, \
+ get_advances_, \
+ \
+ request_size_, \
+ select_size_ \
+ };
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
+#define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \
+ clazz->set_char_sizes = a_; \
+ clazz->set_pixel_sizes = b_;
+#else
+ #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_)
+#endif
+
+#define FT_DECLARE_DRIVER(class_) FT_DECLARE_MODULE(class_)
+
+#define FT_DEFINE_DRIVER(class_, \
+ flags_, size_, name_, version_, requires_, \
+ interface_, init_, done_, get_interface_, \
+ face_object_size_, size_object_size_, \
+ slot_object_size_, init_face_, done_face_, \
+ init_size_, done_size_, init_slot_, done_slot_, \
+ old_set_char_sizes_, old_set_pixel_sizes_, \
+ load_glyph_, get_kerning_, attach_file_, \
+ get_advances_, request_size_, select_size_ ) \
+ void class_##_pic_free( FT_Library library ); \
+ FT_Error class_##_pic_init( FT_Library library ); \
+ \
+ void \
+ FT_Destroy_Class_##class_( FT_Library library, \
+ FT_Module_Class* clazz ) \
+ { \
+ FT_Memory memory = library->memory; \
+ FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \
+ class_##_pic_free( library ); \
+ if ( dclazz ) \
+ FT_FREE( dclazz ); \
+ } \
+ \
+ FT_Error \
+ FT_Create_Class_##class_( FT_Library library, \
+ FT_Module_Class** output_class ) \
+ { \
+ FT_Driver_Class clazz; \
+ FT_Error error; \
+ FT_Memory memory = library->memory; \
+ \
+ if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
+ return error; \
+ \
+ error = class_##_pic_init( library ); \
+ if(error) \
+ { \
+ FT_FREE( clazz ); \
+ return error; \
+ } \
+ \
+ FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \
+ init_,done_,get_interface_) \
+ \
+ clazz->face_object_size = face_object_size_; \
+ clazz->size_object_size = size_object_size_; \
+ clazz->slot_object_size = slot_object_size_; \
+ \
+ clazz->init_face = init_face_; \
+ clazz->done_face = done_face_; \
+ \
+ clazz->init_size = init_size_; \
+ clazz->done_size = done_size_; \
+ \
+ clazz->init_slot = init_slot_; \
+ clazz->done_slot = done_slot_; \
+ \
+ FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \
+ \
+ clazz->load_glyph = load_glyph_; \
+ \
+ clazz->get_kerning = get_kerning_; \
+ clazz->attach_file = attach_file_; \
+ clazz->get_advances = get_advances_; \
+ \
+ clazz->request_size = request_size_; \
+ clazz->select_size = select_size_; \
+ \
+ *output_class = (FT_Module_Class*)clazz; \
+ return FT_Err_Ok; \
+ }
+
+
+#endif /* FT_CONFIG_OPTION_PIC */
FT_END_HEADER
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 1f22343a5..574cf5829 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -35,6 +35,7 @@
#include FT_INTERNAL_DRIVER_H
#include FT_INTERNAL_AUTOHINT_H
#include FT_INTERNAL_SERVICE_H
+#include FT_INTERNAL_PIC_H
#ifdef FT_CONFIG_OPTION_INCREMENTAL
#include FT_INCREMENTAL_H
@@ -205,6 +206,45 @@ FT_BEGIN_HEADER
} FT_CMap_ClassRec;
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FT_DECLARE_CMAP_CLASS(class_) \
+ FT_CALLBACK_TABLE const FT_CMap_ClassRec class_;
+
+#define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_, \
+ char_next_, char_var_index_, char_var_default_, variant_list_, \
+ charvariant_list_, variantchar_list_) \
+ FT_CALLBACK_TABLE_DEF \
+ const FT_CMap_ClassRec class_ = \
+ { \
+ size_, init_, done_, char_index_, char_next_, char_var_index_, \
+ char_var_default_, variant_list_, charvariant_list_, variantchar_list_ \
+ };
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DECLARE_CMAP_CLASS(class_) \
+ void FT_Init_Class_##class_( FT_Library library, FT_CMap_ClassRec* clazz);
+
+#define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_, \
+ char_next_, char_var_index_, char_var_default_, variant_list_, \
+ charvariant_list_, variantchar_list_) \
+ void \
+ FT_Init_Class_##class_( FT_Library library, \
+ FT_CMap_ClassRec* clazz) \
+ { \
+ FT_UNUSED(library); \
+ clazz->size = size_; \
+ clazz->init = init_; \
+ clazz->done = done_; \
+ clazz->char_index = char_index_; \
+ clazz->char_next = char_next_; \
+ clazz->char_var_index = char_var_index_; \
+ clazz->char_var_default = char_var_default_; \
+ clazz->variant_list = variant_list_; \
+ clazz->charvariant_list = charvariant_list_; \
+ clazz->variantchar_list = variantchar_list_; \
+ }
+#endif /* FT_CONFIG_OPTION_PIC */
/* create a new charmap and add it to charmap->face */
FT_BASE( FT_Error )
@@ -765,6 +805,10 @@ FT_BEGIN_HEADER
/* */
/* debug_hooks :: XXX */
/* */
+ /* pic_container :: Contains global structs and tables, instead */
+ /* of defining them globallly. */
+ /* */
+
typedef struct FT_LibraryRec_
{
FT_Memory memory; /* library's memory manager */
@@ -795,6 +839,10 @@ FT_BEGIN_HEADER
FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
#endif
+#ifdef FT_CONFIG_OPTION_PIC
+ FT_PIC_Container pic_container;
+#endif
+
} FT_LibraryRec;
@@ -866,6 +914,484 @@ FT_BEGIN_HEADER
FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster;
#endif
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** ****/
+ /**** PIC-Support Macros for ftimage.h ****/
+ /**** ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_DEFINE_OUTLINE_FUNCS */
+ /* */
+ /* <Description> */
+ /* Used to initialize an instance of FT_Outline_Funcs struct. */
+ /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
+ /* called with a pre-allocated stracture to be filled. */
+ /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
+ /* allocated in the global scope (or the scope where the macro */
+ /* is used). */
+ /* */
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
+ cubic_to_, shift_, delta_) \
+ static const FT_Outline_Funcs class_ = \
+ { \
+ move_to_, line_to_, conic_to_, cubic_to_, shift_, delta_ \
+ };
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
+ cubic_to_, shift_, delta_) \
+ static FT_Error \
+ Init_Class_##class_( FT_Outline_Funcs* clazz ) \
+ { \
+ clazz->move_to = move_to_; \
+ clazz->line_to = line_to_; \
+ clazz->conic_to = conic_to_; \
+ clazz->cubic_to = cubic_to_; \
+ clazz->shift = shift_; \
+ clazz->delta = delta_; \
+ return FT_Err_Ok; \
+ }
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+ /*************************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_DEFINE_RASTER_FUNCS */
+ /* */
+ /* <Description> */
+ /* Used to initialize an instance of FT_Raster_Funcs struct. */
+ /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
+ /* called with a pre-allocated stracture to be filled. */
+ /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
+ /* allocated in the global scope (or the scope where the macro */
+ /* is used). */
+ /* */
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
+ raster_reset_, raster_set_mode_, \
+ raster_render_, raster_done_) \
+ const FT_Raster_Funcs class_ = \
+ { \
+ glyph_format_, raster_new_, raster_reset_, \
+ raster_set_mode_, raster_render_, raster_done_ \
+ };
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
+ raster_reset_, raster_set_mode_, raster_render_, raster_done_) \
+ void \
+ FT_Init_Class_##class_( FT_Raster_Funcs* clazz ) \
+ { \
+ clazz->glyph_format = glyph_format_; \
+ clazz->raster_new = raster_new_; \
+ clazz->raster_reset = raster_reset_; \
+ clazz->raster_set_mode = raster_set_mode_; \
+ clazz->raster_render = raster_render_; \
+ clazz->raster_done = raster_done_; \
+ }
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** ****/
+ /**** PIC-Support Macros for ftrender.h ****/
+ /**** ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+
+ /*************************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_DEFINE_GLYPH */
+ /* */
+ /* <Description> */
+ /* Used to initialize an instance of FT_Glyph_Class struct. */
+ /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
+ /* called with a pre-allocated stracture to be filled. */
+ /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
+ /* allocated in the global scope (or the scope where the macro */
+ /* is used). */
+ /* */
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
+ transform_, bbox_, prepare_) \
+ FT_CALLBACK_TABLE_DEF \
+ const FT_Glyph_Class class_ = \
+ { \
+ size_, format_, init_, done_, copy_, transform_, bbox_, prepare_ \
+ };
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
+ transform_, bbox_, prepare_) \
+ void \
+ FT_Init_Class_##class_( FT_Glyph_Class* clazz ) \
+ { \
+ clazz->glyph_size = size_; \
+ clazz->glyph_format = format_; \
+ clazz->glyph_init = init_; \
+ clazz->glyph_done = done_; \
+ clazz->glyph_copy = copy_; \
+ clazz->glyph_transform = transform_; \
+ clazz->glyph_bbox = bbox_; \
+ clazz->glyph_prepare = prepare_; \
+ }
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+ /*************************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_DECLARE_RENDERER */
+ /* */
+ /* <Description> */
+ /* Used to create a forward declaration of a */
+ /* FT_Renderer_Class stract instance. */
+ /* */
+ /* <Macro> */
+ /* FT_DEFINE_RENDERER */
+ /* */
+ /* <Description> */
+ /* Used to initialize an instance of FT_Renderer_Class struct. */
+ /* */
+ /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
+ /* to called with a pointer where the allocated stracture is returned.*/
+ /* And when it is no longer needed a Destroy function needs */
+ /* to be called to release that allocation. */
+ /* fcinit.c (ft_create_default_module_classes) already contains */
+ /* a mechanism to call these functions for the default modules */
+ /* described in ftmodule.h */
+ /* */
+ /* Notice that the created Create and Destroy functions call */
+ /* pic_init and pic_free function to allow you to manually allocate */
+ /* and initialize any additional global data, like module specific */
+ /* interface, and put them in the global pic container defined in */
+ /* ftpic.h. if you don't need them just implement the functions as */
+ /* empty to resolve the link error. */
+ /* */
+ /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
+ /* allocated in the global scope (or the scope where the macro */
+ /* is used). */
+ /* */
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FT_DECLARE_RENDERER(class_) \
+ FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
+
+#define FT_DEFINE_RENDERER(class_, \
+ flags_, size_, name_, version_, requires_, \
+ interface_, init_, done_, get_interface_, \
+ glyph_format_, render_glyph_, transform_glyph_, \
+ get_glyph_cbox_, set_mode_, raster_class_ ) \
+ FT_CALLBACK_TABLE_DEF \
+ const FT_Renderer_Class class_ = \
+ { \
+ FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_, \
+ interface_,init_,done_,get_interface_) \
+ glyph_format_, \
+ \
+ render_glyph_, \
+ transform_glyph_, \
+ get_glyph_cbox_, \
+ set_mode_, \
+ \
+ raster_class_ \
+ };
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DECLARE_RENDERER(class_) FT_DECLARE_MODULE(class_)
+
+#define FT_DEFINE_RENDERER(class_, \
+ flags_, size_, name_, version_, requires_, \
+ interface_, init_, done_, get_interface_, \
+ glyph_format_, render_glyph_, transform_glyph_, \
+ get_glyph_cbox_, set_mode_, raster_class_ ) \
+ void class_##_pic_free( FT_Library library ); \
+ FT_Error class_##_pic_init( FT_Library library ); \
+ \
+ void \
+ FT_Destroy_Class_##class_( FT_Library library, \
+ FT_Module_Class* clazz ) \
+ { \
+ FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \
+ FT_Memory memory = library->memory; \
+ class_##_pic_free( library ); \
+ if ( rclazz ) \
+ FT_FREE( rclazz ); \
+ } \
+ \
+ FT_Error \
+ FT_Create_Class_##class_( FT_Library library, \
+ FT_Module_Class** output_class ) \
+ { \
+ FT_Renderer_Class* clazz; \
+ FT_Error error; \
+ FT_Memory memory = library->memory; \
+ \
+ if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
+ return error; \
+ \
+ error = class_##_pic_init( library ); \
+ if(error) \
+ { \
+ FT_FREE( clazz ); \
+ return error; \
+ } \
+ \
+ FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_, \
+ interface_,init_,done_,get_interface_) \
+ \
+ clazz->glyph_format = glyph_format_; \
+ \
+ clazz->render_glyph = render_glyph_; \
+ clazz->transform_glyph = transform_glyph_; \
+ clazz->get_glyph_cbox = get_glyph_cbox_; \
+ clazz->set_mode = set_mode_; \
+ \
+ clazz->raster_class = raster_class_; \
+ \
+ *output_class = (FT_Module_Class*)clazz; \
+ return FT_Err_Ok; \
+ }
+
+
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** ****/
+ /**** PIC-Support Macros for ftmodapi.h ****/
+ /**** ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+#ifdef FT_CONFIG_OPTION_PIC
+
+ /*************************************************************************/
+ /* */
+ /* <FuncType> */
+ /* FT_Module_Creator */
+ /* */
+ /* <Description> */
+ /* A function used to create (allocate) a new module class object. */
+ /* The object's members are initialized, but the module itself is */
+ /* not. */
+ /* */
+ /* <Input> */
+ /* memory :: A handle to the memory manager. */
+ /* output_class :: Initialized with the newly allocated class. */
+ /* */
+ typedef FT_Error
+ (*FT_Module_Creator)( FT_Memory memory,
+ FT_Module_Class** output_class );
+
+ /*************************************************************************/
+ /* */
+ /* <FuncType> */
+ /* FT_Module_Destroyer */
+ /* */
+ /* <Description> */
+ /* A function used to destroy (deallocate) a module class object. */
+ /* */
+ /* <Input> */
+ /* memory :: A handle to the memory manager. */
+ /* clazz :: Module class to destroy. */
+ /* */
+ typedef void
+ (*FT_Module_Destroyer)( FT_Memory memory,
+ FT_Module_Class* clazz );
+
+#endif
+
+ /*************************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_DECLARE_MODULE */
+ /* */
+ /* <Description> */
+ /* Used to create a forward declaration of a */
+ /* FT_Module_Class stract instance. */
+ /* */
+ /* <Macro> */
+ /* FT_DEFINE_MODULE */
+ /* */
+ /* <Description> */
+ /* Used to initialize an instance of FT_Module_Class struct. */
+ /* */
+ /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
+ /* to called with a pointer where the allocated stracture is returned.*/
+ /* And when it is no longer needed a Destroy function needs */
+ /* to be called to release that allocation. */
+ /* fcinit.c (ft_create_default_module_classes) already contains */
+ /* a mechanism to call these functions for the default modules */
+ /* described in ftmodule.h */
+ /* */
+ /* Notice that the created Create and Destroy functions call */
+ /* pic_init and pic_free function to allow you to manually allocate */
+ /* and initialize any additional global data, like module specific */
+ /* interface, and put them in the global pic container defined in */
+ /* ftpic.h. if you don't need them just implement the functions as */
+ /* empty to resolve the link error. */
+ /* */
+ /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
+ /* allocated in the global scope (or the scope where the macro */
+ /* is used). */
+ /* */
+ /* <Macro> */
+ /* FT_DEFINE_ROOT_MODULE */
+ /* */
+ /* <Description> */
+ /* Used to initialize an instance of FT_Module_Class struct inside */
+ /* another stract that contains it or in a function that initializes */
+ /* that containing stract */
+ /* */
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FT_DECLARE_MODULE(class_) \
+ FT_CALLBACK_TABLE \
+ const FT_Module_Class class_; \
+
+#define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_, \
+ interface_, init_, done_, get_interface_) \
+ { \
+ flags_, \
+ size_, \
+ \
+ name_, \
+ version_, \
+ requires_, \
+ \
+ interface_, \
+ \
+ init_, \
+ done_, \
+ get_interface_, \
+ },
+
+#define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_, \
+ interface_, init_, done_, get_interface_) \
+ FT_CALLBACK_TABLE_DEF \
+ const FT_Module_Class class_ = \
+ { \
+ flags_, \
+ size_, \
+ \
+ name_, \
+ version_, \
+ requires_, \
+ \
+ interface_, \
+ \
+ init_, \
+ done_, \
+ get_interface_, \
+ };
+
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DECLARE_MODULE(class_) \
+ FT_Error FT_Create_Class_##class_( FT_Library library, \
+ FT_Module_Class** output_class ); \
+ void FT_Destroy_Class_##class_( FT_Library library, \
+ FT_Module_Class* clazz );
+
+#define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_, \
+ interface_, init_, done_, get_interface_) \
+ clazz->root.module_flags = flags_; \
+ clazz->root.module_size = size_; \
+ clazz->root.module_name = name_; \
+ clazz->root.module_version = version_; \
+ clazz->root.module_requires = requires_; \
+ \
+ clazz->root.module_interface = interface_; \
+ \
+ clazz->root.module_init = init_; \
+ clazz->root.module_done = done_; \
+ clazz->root.get_interface = get_interface_;
+
+#define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_, \
+ interface_, init_, done_, get_interface_) \
+ void class_##_pic_free( FT_Library library ); \
+ FT_Error class_##_pic_init( FT_Library library ); \
+ \
+ void \
+ FT_Destroy_Class_##class_( FT_Library library, \
+ FT_Module_Class* clazz ) \
+ { \
+ FT_Memory memory = library->memory; \
+ class_##_pic_free( library ); \
+ if ( clazz ) \
+ FT_FREE( clazz ); \
+ } \
+ \
+ FT_Error \
+ FT_Create_Class_##class_( FT_Library library, \
+ FT_Module_Class** output_class ) \
+ { \
+ FT_Memory memory = library->memory; \
+ FT_Module_Class* clazz; \
+ FT_Error error; \
+ \
+ if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
+ return error; \
+ error = class_##_pic_init( library ); \
+ if(error) \
+ { \
+ FT_FREE( clazz ); \
+ return error; \
+ } \
+ \
+ clazz->module_flags = flags_; \
+ clazz->module_size = size_; \
+ clazz->module_name = name_; \
+ clazz->module_version = version_; \
+ clazz->module_requires = requires_; \
+ \
+ clazz->module_interface = interface_; \
+ \
+ clazz->module_init = init_; \
+ clazz->module_done = done_; \
+ clazz->get_interface = get_interface_; \
+ \
+ *output_class = clazz; \
+ return FT_Err_Ok; \
+ }
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
FT_END_HEADER
diff --git a/include/freetype/internal/ftpic.h b/include/freetype/internal/ftpic.h
new file mode 100644
index 000000000..1b31957d7
--- /dev/null
+++ b/include/freetype/internal/ftpic.h
@@ -0,0 +1,67 @@
+/***************************************************************************/
+/* */
+/* ftpic.h */
+/* */
+/* The FreeType position independent code services (declaration). */
+/* */
+/* Copyright 2009 by */
+/* Oran Agra and Mickey Gabel. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* Modules that ordinarily have const global data that need address */
+ /* can instead define pointers here. */
+ /* */
+ /*************************************************************************/
+
+
+#ifndef __FTPIC_H__
+#define __FTPIC_H__
+
+
+FT_BEGIN_HEADER
+
+#ifdef FT_CONFIG_OPTION_PIC
+
+ typedef struct FT_PIC_Container_
+ {
+ /* pic containers for base */
+ void* base;
+ /* pic containers for modules */
+ void* autofit;
+ void* cff;
+ void* pshinter;
+ void* psnames;
+ void* raster;
+ void* sfnt;
+ void* smooth;
+ void* truetype;
+ } FT_PIC_Container;
+
+ /* Initialize the various function tables, structs, etc. stored in the container. */
+ FT_BASE( FT_Error )
+ ft_pic_container_init( FT_Library library );
+
+
+ /* Destroy the contents of the container. */
+ FT_BASE( void )
+ ft_pic_container_destroy( FT_Library library );
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __FTPIC_H__ */
+
+
+/* END */
diff --git a/include/freetype/internal/ftserv.h b/include/freetype/internal/ftserv.h
index 2db3e8790..569b9f7e0 100644
--- a/include/freetype/internal/ftserv.h
+++ b/include/freetype/internal/ftserv.h
@@ -163,6 +163,298 @@ FT_BEGIN_HEADER
typedef const FT_ServiceDescRec* FT_ServiceDesc;
+ /*************************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_DEFINE_SERVICEDESCREC1 .. FT_DEFINE_SERVICEDESCREC6 */
+ /* */
+ /* <Description> */
+ /* Used to initialize an array of FT_ServiceDescRec structs. */
+ /* */
+ /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
+ /* to called with a pointer where the allocated array is returned. */
+ /* And when it is no longer needed a Destroy function needs */
+ /* to be called to release that allocation. */
+ /* */
+ /* These functions should be manyally called from the pic_init and */
+ /* pic_free functions of your module (see FT_DEFINE_MODULE) */
+ /* */
+ /* When FT_CONFIG_OPTION_PIC is not defined the array will be */
+ /* allocated in the global scope (or the scope where the macro */
+ /* is used). */
+ /* */
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FT_DEFINE_SERVICEDESCREC1(class_, serv_id_1, serv_data_1) \
+ static const FT_ServiceDescRec class_[] = \
+ { \
+ {serv_id_1, serv_data_1}, \
+ {NULL, NULL} \
+ };
+#define FT_DEFINE_SERVICEDESCREC2(class_, serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2) \
+ static const FT_ServiceDescRec class_[] = \
+ { \
+ {serv_id_1, serv_data_1}, \
+ {serv_id_2, serv_data_2}, \
+ {NULL, NULL} \
+ };
+#define FT_DEFINE_SERVICEDESCREC3(class_, serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2, serv_id_3, serv_data_3) \
+ static const FT_ServiceDescRec class_[] = \
+ { \
+ {serv_id_1, serv_data_1}, \
+ {serv_id_2, serv_data_2}, \
+ {serv_id_3, serv_data_3}, \
+ {NULL, NULL} \
+ };
+#define FT_DEFINE_SERVICEDESCREC4(class_, serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
+ serv_id_4, serv_data_4) \
+ static const FT_ServiceDescRec class_[] = \
+ { \
+ {serv_id_1, serv_data_1}, \
+ {serv_id_2, serv_data_2}, \
+ {serv_id_3, serv_data_3}, \
+ {serv_id_4, serv_data_4}, \
+ {NULL, NULL} \
+ };
+#define FT_DEFINE_SERVICEDESCREC5(class_, serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
+ serv_id_4, serv_data_4, serv_id_5, serv_data_5) \
+ static const FT_ServiceDescRec class_[] = \
+ { \
+ {serv_id_1, serv_data_1}, \
+ {serv_id_2, serv_data_2}, \
+ {serv_id_3, serv_data_3}, \
+ {serv_id_4, serv_data_4}, \
+ {serv_id_5, serv_data_5}, \
+ {NULL, NULL} \
+ };
+#define FT_DEFINE_SERVICEDESCREC6(class_, serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
+ serv_id_4, serv_data_4, serv_id_5, serv_data_5, \
+ serv_id_6, serv_data_6) \
+ static const FT_ServiceDescRec class_[] = \
+ { \
+ {serv_id_1, serv_data_1}, \
+ {serv_id_2, serv_data_2}, \
+ {serv_id_3, serv_data_3}, \
+ {serv_id_4, serv_data_4}, \
+ {serv_id_5, serv_data_5}, \
+ {serv_id_6, serv_data_6}, \
+ {NULL, NULL} \
+ };
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DEFINE_SERVICEDESCREC1(class_, serv_id_1, serv_data_1) \
+ void \
+ FT_Destroy_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec* clazz ) \
+ { \
+ FT_Memory memory = library->memory; \
+ if ( clazz ) \
+ FT_FREE( clazz ); \
+ } \
+ \
+ FT_Error \
+ FT_Create_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec** output_class) \
+ { \
+ FT_ServiceDescRec* clazz; \
+ FT_Error error; \
+ FT_Memory memory = library->memory; \
+ \
+ if ( FT_ALLOC( clazz, sizeof(*clazz)*2 ) ) \
+ return error; \
+ clazz[0].serv_id = serv_id_1; \
+ clazz[0].serv_data = serv_data_1; \
+ clazz[1].serv_id = NULL; \
+ clazz[1].serv_data = NULL; \
+ *output_class = clazz; \
+ return FT_Err_Ok; \
+ }
+
+#define FT_DEFINE_SERVICEDESCREC2(class_, serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2) \
+ void \
+ FT_Destroy_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec* clazz ) \
+ { \
+ FT_Memory memory = library->memory; \
+ if ( clazz ) \
+ FT_FREE( clazz ); \
+ } \
+ \
+ FT_Error \
+ FT_Create_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec** output_class) \
+ { \
+ FT_ServiceDescRec* clazz; \
+ FT_Error error; \
+ FT_Memory memory = library->memory; \
+ \
+ if ( FT_ALLOC( clazz, sizeof(*clazz)*3 ) ) \
+ return error; \
+ clazz[0].serv_id = serv_id_1; \
+ clazz[0].serv_data = serv_data_1; \
+ clazz[1].serv_id = serv_id_2; \
+ clazz[1].serv_data = serv_data_2; \
+ clazz[2].serv_id = NULL; \
+ clazz[2].serv_data = NULL; \
+ *output_class = clazz; \
+ return FT_Err_Ok; \
+ }
+
+#define FT_DEFINE_SERVICEDESCREC3(class_, serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2, serv_id_3, serv_data_3) \
+ void \
+ FT_Destroy_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec* clazz ) \
+ { \
+ FT_Memory memory = library->memory; \
+ if ( clazz ) \
+ FT_FREE( clazz ); \
+ } \
+ \
+ FT_Error \
+ FT_Create_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec** output_class) \
+ { \
+ FT_ServiceDescRec* clazz; \
+ FT_Error error; \
+ FT_Memory memory = library->memory; \
+ \
+ if ( FT_ALLOC( clazz, sizeof(*clazz)*4 ) ) \
+ return error; \
+ clazz[0].serv_id = serv_id_1; \
+ clazz[0].serv_data = serv_data_1; \
+ clazz[1].serv_id = serv_id_2; \
+ clazz[1].serv_data = serv_data_2; \
+ clazz[2].serv_id = serv_id_3; \
+ clazz[2].serv_data = serv_data_3; \
+ clazz[3].serv_id = NULL; \
+ clazz[3].serv_data = NULL; \
+ *output_class = clazz; \
+ return FT_Err_Ok; \
+ }
+
+#define FT_DEFINE_SERVICEDESCREC4(class_, serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
+ serv_id_4, serv_data_4) \
+ void \
+ FT_Destroy_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec* clazz ) \
+ { \
+ FT_Memory memory = library->memory; \
+ if ( clazz ) \
+ FT_FREE( clazz ); \
+ } \
+ \
+ FT_Error \
+ FT_Create_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec** output_class) \
+ { \
+ FT_ServiceDescRec* clazz; \
+ FT_Error error; \
+ FT_Memory memory = library->memory; \
+ \
+ if ( FT_ALLOC( clazz, sizeof(*clazz)*5 ) ) \
+ return error; \
+ clazz[0].serv_id = serv_id_1; \
+ clazz[0].serv_data = serv_data_1; \
+ clazz[1].serv_id = serv_id_2; \
+ clazz[1].serv_data = serv_data_2; \
+ clazz[2].serv_id = serv_id_3; \
+ clazz[2].serv_data = serv_data_3; \
+ clazz[3].serv_id = serv_id_4; \
+ clazz[3].serv_data = serv_data_4; \
+ clazz[4].serv_id = NULL; \
+ clazz[4].serv_data = NULL; \
+ *output_class = clazz; \
+ return FT_Err_Ok; \
+ }
+
+#define FT_DEFINE_SERVICEDESCREC5(class_, serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2, serv_id_3, serv_data_3, serv_id_4, \
+ serv_data_4, serv_id_5, serv_data_5) \
+ void \
+ FT_Destroy_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec* clazz ) \
+ { \
+ FT_Memory memory = library->memory; \
+ if ( clazz ) \
+ FT_FREE( clazz ); \
+ } \
+ \
+ FT_Error \
+ FT_Create_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec** output_class) \
+ { \
+ FT_ServiceDescRec* clazz; \
+ FT_Error error; \
+ FT_Memory memory = library->memory; \
+ \
+ if ( FT_ALLOC( clazz, sizeof(*clazz)*6 ) ) \
+ return error; \
+ clazz[0].serv_id = serv_id_1; \
+ clazz[0].serv_data = serv_data_1; \
+ clazz[1].serv_id = serv_id_2; \
+ clazz[1].serv_data = serv_data_2; \
+ clazz[2].serv_id = serv_id_3; \
+ clazz[2].serv_data = serv_data_3; \
+ clazz[3].serv_id = serv_id_4; \
+ clazz[3].serv_data = serv_data_4; \
+ clazz[4].serv_id = serv_id_5; \
+ clazz[4].serv_data = serv_data_5; \
+ clazz[5].serv_id = NULL; \
+ clazz[5].serv_data = NULL; \
+ *output_class = clazz; \
+ return FT_Err_Ok; \
+ }
+
+#define FT_DEFINE_SERVICEDESCREC6(class_, serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
+ serv_id_4, serv_data_4, serv_id_5, serv_data_5, \
+ serv_id_6, serv_data_6) \
+ void \
+ FT_Destroy_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec* clazz ) \
+ { \
+ FT_Memory memory = library->memory; \
+ if ( clazz ) \
+ FT_FREE( clazz ); \
+ } \
+ \
+ FT_Error \
+ FT_Create_Class_##class_( FT_Library library, \
+ FT_ServiceDescRec** output_class) \
+ { \
+ FT_ServiceDescRec* clazz; \
+ FT_Error error; \
+ FT_Memory memory = library->memory; \
+ \
+ if ( FT_ALLOC( clazz, sizeof(*clazz)*7 ) ) \
+ return error; \
+ clazz[0].serv_id = serv_id_1; \
+ clazz[0].serv_data = serv_data_1; \
+ clazz[1].serv_id = serv_id_2; \
+ clazz[1].serv_data = serv_data_2; \
+ clazz[2].serv_id = serv_id_3; \
+ clazz[2].serv_data = serv_data_3; \
+ clazz[3].serv_id = serv_id_4; \
+ clazz[3].serv_data = serv_data_4; \
+ clazz[4].serv_id = serv_id_5; \
+ clazz[4].serv_data = serv_data_5; \
+ clazz[5].serv_id = serv_id_6; \
+ clazz[5].serv_data = serv_data_6; \
+ clazz[6].serv_id = NULL; \
+ clazz[6].serv_data = NULL; \
+ *output_class = clazz; \
+ return FT_Err_Ok; \
+ }
+#endif /* FT_CONFIG_OPTION_PIC */
/*
* Parse a list of FT_ServiceDescRec descriptors and look for
diff --git a/include/freetype/internal/internal.h b/include/freetype/internal/internal.h
index 27d5dc585..f500a651c 100644
--- a/include/freetype/internal/internal.h
+++ b/include/freetype/internal/internal.h
@@ -25,6 +25,7 @@
#define FT_INTERNAL_OBJECTS_H <freetype/internal/ftobjs.h>
+#define FT_INTERNAL_PIC_H <freetype/internal/ftpic.h>
#define FT_INTERNAL_STREAM_H <freetype/internal/ftstream.h>
#define FT_INTERNAL_MEMORY_H <freetype/internal/ftmemory.h>
#define FT_INTERNAL_DEBUG_H <freetype/internal/ftdebug.h>