[autofit] Implement properties service framework. No properties are added yet. * src/autofit/afmodule.c: Include FT_SERVICE_PROPERTIES_H. (af_property_set, af_property_get): New dummy functions. (af_service_properties, af_services, af_get_interface): Provide service setup. (autofit_moduleclass): Add service interface. * src/autofit/afpic.c: Add necessary forward declarations. (autofit_module_class_pic_init): Add code for service addition. (autofit_module_pic_free): Add code for service removal. * src/autofit/afpic.h (AF_SERVICES_GET, AF_SERVICE_PROPERTIES_GET): New macros which provide necessary syntactical sugar for PIC support.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
diff --git a/ChangeLog b/ChangeLog
index 0322f01..79ada24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2012-08-31 Werner Lemberg <wl@gnu.org>
+
+ [autofit] Implement properties service framework.
+
+ No properties are added yet.
+
+ * src/autofit/afmodule.c: Include FT_SERVICE_PROPERTIES_H.
+ (af_property_set, af_property_get): New dummy functions.
+ (af_service_properties, af_services, af_get_interface): Provide
+ service setup.
+ (autofit_moduleclass): Add service interface.
+
+ * src/autofit/afpic.c: Add necessary forward declarations.
+ (autofit_module_class_pic_init): Add code for service addition.
+ (autofit_module_pic_free): Add code for service removal.
+ * src/autofit/afpic.h (AF_SERVICES_GET, AF_SERVICE_PROPERTIES_GET):
+ New macros which provide necessary syntactical sugar for PIC
+ support.
+
2012-08-30 Werner Lemberg <wl@gnu.org>
Implement properties to control FreeType modules.
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index 04cd894..ce20866 100644
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -28,6 +28,68 @@
#endif
#include FT_INTERNAL_OBJECTS_H
+#include FT_SERVICE_PROPERTIES_H
+
+
+ FT_Error
+ af_property_set( FT_Library library,
+ const char* property_name,
+ const void* value )
+ {
+ FT_UNUSED( library );
+ FT_UNUSED( value );
+
+ FT_TRACE0(( "af_property_get: missing property `%s'\n",
+ property_name ));
+ return FT_Err_Missing_Property;
+ }
+
+
+ FT_Error
+ af_property_get( FT_Library library,
+ const char* property_name,
+ void* value )
+ {
+ FT_UNUSED( library );
+ FT_UNUSED( value );
+
+ FT_TRACE0(( "af_property_get: missing property `%s'\n",
+ property_name ));
+ return FT_Err_Missing_Property;
+ }
+
+
+ FT_DEFINE_SERVICE_PROPERTIESREC(
+ af_service_properties,
+ (FT_Properties_SetFunc)af_property_set,
+ (FT_Properties_GetFunc)af_property_get )
+
+
+ FT_DEFINE_SERVICEDESCREC1(
+ af_services,
+ FT_SERVICE_ID_PROPERTIES, &AF_SERVICE_PROPERTIES_GET )
+
+
+ FT_CALLBACK_DEF( FT_Module_Interface )
+ af_get_interface( FT_Module module,
+ const char* module_interface )
+ {
+ /* AF_SERVICES_GET derefers `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+ FT_Library library;
+
+
+ if ( !module )
+ return NULL;
+ library = module->library;
+ if ( !library )
+ return NULL;
+#else
+ FT_UNUSED( module );
+#endif
+
+ return ft_service_list_lookup( AF_SERVICES_GET, module_interface );
+ }
typedef struct FT_AutofitterRec_
@@ -88,7 +150,7 @@
(FT_Module_Constructor)af_autofitter_init,
(FT_Module_Destructor) af_autofitter_done,
- (FT_Module_Requester) NULL )
+ (FT_Module_Requester) af_get_interface )
/* END */
diff --git a/src/autofit/afpic.c b/src/autofit/afpic.c
index 36a9cca..e6022f9 100644
--- a/src/autofit/afpic.c
+++ b/src/autofit/afpic.c
@@ -26,10 +26,22 @@
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from afmodule.c */
+ FT_Error
+ FT_Create_Class_af_services( FT_Library library,
+ FT_ServiceDescRec** output_class );
+
+ void
+ FT_Destroy_Class_af_services( FT_Library library,
+ FT_ServiceDescRec* clazz );
+
+ void
+ FT_Init_Class_af_service_properties( FT_Service_PropertiesRec* clazz );
+
void FT_Init_Class_af_autofitter_interface(
FT_Library library,
FT_AutoHinter_InterfaceRec* clazz );
+
/* forward declaration of PIC init functions from script classes */
#include "aflatin.h"
#ifdef FT_OPTION_AUTOFIT2
@@ -49,7 +61,15 @@
if ( pic_container->autofit )
{
- FT_FREE( pic_container->autofit );
+ AFModulePIC* container = (AFModulePIC*)pic_container->autofit;
+
+
+ if ( container->af_services )
+ FT_Destroy_Class_af_services( library,
+ container->af_services );
+ container->af_services = NULL;
+
+ FT_FREE( container );
pic_container->autofit = NULL;
}
}
@@ -73,6 +93,13 @@
/* initialize pointer table - */
/* this is how the module usually expects this data */
+ error = FT_Create_Class_af_services( library,
+ &container->af_services );
+ if ( error )
+ goto Exit;
+
+ FT_Init_Class_af_service_properties( &container->af_service_properties );
+
for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
{
container->af_script_classes[ss] =
@@ -98,8 +125,7 @@
FT_Init_Class_af_autofitter_interface(
library, &container->af_autofitter_interface );
-/* Exit: */
-
+ Exit:
if ( error )
autofit_module_class_pic_free( library );
return error;
diff --git a/src/autofit/afpic.h b/src/autofit/afpic.h
index 41c832a..7a07bdf 100644
--- a/src/autofit/afpic.h
+++ b/src/autofit/afpic.h
@@ -27,11 +27,17 @@ FT_BEGIN_HEADER
#ifndef FT_CONFIG_OPTION_PIC
-#define AF_SCRIPT_CLASSES_GET af_script_classes
-#define AF_INTERFACE_GET af_autofitter_interface
+#define AF_SERVICES_GET af_services
+#define AF_SERVICE_PROPERTIES_GET af_service_properties
+
+#define AF_SCRIPT_CLASSES_GET af_script_classes
+#define AF_INTERFACE_GET af_autofitter_interface
#else /* FT_CONFIG_OPTION_PIC */
+ /* some include files required for members of AFModulePIC */
+#include FT_SERVICE_PROPERTIES_H
+
#include "aftypes.h"
/* increase these when you add new scripts, */
@@ -47,6 +53,9 @@ FT_BEGIN_HEADER
typedef struct AFModulePIC_
{
+ FT_ServiceDescRec* af_services;
+ FT_Service_PropertiesRec af_service_properties;
+
AF_ScriptClass af_script_classes[AF_SCRIPT_CLASSES_COUNT];
AF_ScriptClassRec af_script_classes_rec[AF_SCRIPT_CLASSES_REC_COUNT];
FT_AutoHinter_InterfaceRec af_autofitter_interface;
@@ -57,6 +66,11 @@ FT_BEGIN_HEADER
#define GET_PIC( lib ) \
( (AFModulePIC*)((lib)->pic_container.autofit) )
+#define AF_SERVICES_GET \
+ ( GET_PIC( library )->af_services )
+#define AF_SERVICE_PROPERTIES_GET \
+ ( GET_PIC( library)->af_service_properties )
+
#define AF_SCRIPT_CLASSES_GET \
( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_script_classes )
#define AF_INTERFACE_GET \