00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include <ft2build.h>
00041 #include FT_CONFIG_CONFIG_H
00042 #include FT_INTERNAL_OBJECTS_H
00043 #include FT_INTERNAL_DEBUG_H
00044 #include FT_MODULE_H
00045 #include "basepic.h"
00046
00047
00048
00049
00050
00051
00052
00053
00054 #undef FT_COMPONENT
00055 #define FT_COMPONENT trace_init
00056
00057 #ifndef FT_CONFIG_OPTION_PIC
00058
00059 #undef FT_USE_MODULE
00060 #ifdef __cplusplus
00061 #define FT_USE_MODULE( type, x ) extern "C" const type x;
00062 #else
00063 #define FT_USE_MODULE( type, x ) extern const type x;
00064 #endif
00065
00066
00067 #include FT_CONFIG_MODULES_H
00068
00069
00070 #undef FT_USE_MODULE
00071 #define FT_USE_MODULE( type, x ) (const FT_Module_Class*)&(x),
00072
00073 static
00074 const FT_Module_Class* const ft_default_modules[] =
00075 {
00076 #include FT_CONFIG_MODULES_H
00077 0
00078 };
00079
00080 #else
00081
00082 #ifdef __cplusplus
00083 #define FT_EXTERNC extern "C"
00084 #else
00085 #define FT_EXTERNC extern
00086 #endif
00087
00088
00089 #undef FT_USE_MODULE
00090 #define FT_USE_MODULE( type, x ) \
00091 FT_EXTERNC FT_Error FT_Create_Class_##x( FT_Library library, FT_Module_Class** output_class ); \
00092 FT_EXTERNC void FT_Destroy_Class_##x( FT_Library library, FT_Module_Class* clazz );
00093
00094 #include FT_CONFIG_MODULES_H
00095
00096
00097
00098 #undef FT_USE_MODULE
00099 #define FT_USE_MODULE( type, x ) MODULE_CLASS_##x,
00100
00101 enum {
00102 #include FT_CONFIG_MODULES_H
00103 FT_NUM_MODULE_CLASSES
00104 };
00105
00106
00107 #undef FT_USE_MODULE
00108 #define FT_USE_MODULE( type, x ) \
00109 if ( classes[i] ) { FT_Destroy_Class_##x(library, classes[i]); } \
00110 i++; \
00111
00112 FT_BASE_DEF( void )
00113 ft_destroy_default_module_classes( FT_Library library )
00114 {
00115 FT_Module_Class** classes;
00116 FT_Memory memory;
00117 FT_UInt i;
00118 BasePIC* pic_container = (BasePIC*)library->pic_container.base;
00119
00120 if ( !pic_container->default_module_classes )
00121 return;
00122
00123 memory = library->memory;
00124 classes = pic_container->default_module_classes;
00125 i = 0;
00126
00127 #include FT_CONFIG_MODULES_H
00128
00129 FT_FREE( classes );
00130 pic_container->default_module_classes = 0;
00131 }
00132
00133
00134 #undef FT_USE_MODULE
00135 #define FT_USE_MODULE( type, x ) \
00136 error = FT_Create_Class_##x(library, &clazz); \
00137 if (error) goto Exit; \
00138 classes[i++] = clazz;
00139
00140 FT_BASE_DEF( FT_Error )
00141 ft_create_default_module_classes( FT_Library library )
00142 {
00143 FT_Error error;
00144 FT_Memory memory;
00145 FT_Module_Class** classes;
00146 FT_Module_Class* clazz;
00147 FT_UInt i;
00148 BasePIC* pic_container = (BasePIC*)library->pic_container.base;
00149
00150 memory = library->memory;
00151 pic_container->default_module_classes = 0;
00152
00153 if ( FT_ALLOC(classes, sizeof(FT_Module_Class*) * (FT_NUM_MODULE_CLASSES + 1) ) )
00154 return error;
00155
00156 for (i = 0; i < FT_NUM_MODULE_CLASSES; i++)
00157 classes[i] = 0;
00158 classes[FT_NUM_MODULE_CLASSES] = 0;
00159
00160 i = 0;
00161
00162 #include FT_CONFIG_MODULES_H
00163
00164 Exit:
00165 if (error) ft_destroy_default_module_classes( library );
00166 else pic_container->default_module_classes = classes;
00167
00168 return error;
00169 }
00170
00171
00172 #endif
00173
00174
00175
00176 FT_EXPORT_DEF( void )
00177 FT_Add_Default_Modules( FT_Library library )
00178 {
00179 FT_Error error;
00180 const FT_Module_Class* const* cur;
00181
00182
00183
00184
00185 cur = FT_DEFAULT_MODULES_GET;
00186 while ( *cur )
00187 {
00188 error = FT_Add_Module( library, *cur );
00189
00190 if ( error )
00191 FT_TRACE0(( "FT_Add_Default_Module:"
00192 " Cannot install `%s', error = 0x%x\n",
00193 (*cur)->module_name, error ));
00194 cur++;
00195 }
00196 }
00197
00198
00199
00200
00201 FT_EXPORT_DEF( FT_Error )
00202 FT_Init_FreeType( FT_Library *alibrary )
00203 {
00204 FT_Error error;
00205 FT_Memory memory;
00206
00207
00208
00209
00210
00211 memory = FT_New_Memory();
00212 if ( !memory )
00213 {
00214 FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
00215 return FT_Err_Unimplemented_Feature;
00216 }
00217
00218
00219
00220
00221 error = FT_New_Library( memory, alibrary );
00222 if ( error )
00223 FT_Done_Memory( memory );
00224 else
00225 FT_Add_Default_Modules( *alibrary );
00226
00227 return error;
00228 }
00229
00230
00231
00232
00233 FT_EXPORT_DEF( FT_Error )
00234 FT_Done_FreeType( FT_Library library )
00235 {
00236 if ( library )
00237 {
00238 FT_Memory memory = library->memory;
00239
00240
00241
00242 FT_Done_Library( library );
00243
00244
00245 FT_Done_Memory( memory );
00246 }
00247
00248 return FT_Err_Ok;
00249 }
00250
00251
00252