summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Turner <digit@digit-pad.(none)>2009-04-13 00:33:12 +0200
committerDavid Turner <digit@digit-pad.(none)>2009-04-13 00:33:12 +0200
commit329d42d9eb0327605c592b628a8f68fd7a60e792 (patch)
treed8858257216ee491be766dc9925bb93e5905d32f
parent929ff6996c020b7cda3c8d928cf3f2de4b063708 (diff)
downloadfreetype2-329d42d9eb0327605c592b628a8f68fd7a60e792.tar.gz
convert autofit module to FT_PicData
-rw-r--r--include/freetype/internal/ftpic.h2
-rw-r--r--src/autofit/afpic.c56
-rw-r--r--src/autofit/afpic.h25
3 files changed, 33 insertions, 50 deletions
diff --git a/include/freetype/internal/ftpic.h b/include/freetype/internal/ftpic.h
index f887a0f67..b9d6afece 100644
--- a/include/freetype/internal/ftpic.h
+++ b/include/freetype/internal/ftpic.h
@@ -94,13 +94,13 @@ FT_BEGIN_HEADER
*/
#define FT_PIC_ENTRY_LIST \
_FT_PICDATA( base ) \
+ _FT_PICDATA( autofit ) \
/* now define the entries in the PIC table itself */
#define _FT_PICDATA(name) FT_PicDataRec name [1];
FT_PIC_ENTRY_LIST
#undef _FT_PICDATA
- void* autofit;
void* cff;
void* pshinter;
void* psnames;
diff --git a/src/autofit/afpic.c b/src/autofit/afpic.c
index 66497ba8a..7f6cbb5d4 100644
--- a/src/autofit/afpic.c
+++ b/src/autofit/afpic.c
@@ -33,35 +33,11 @@
#include "afdummy.h"
#include "afindic.h"
- void
- autofit_module_class_pic_free( FT_Library library )
+ static FT_Error
+ pic_autofit_init( void* _autofit, FT_PicTable pic )
{
- FT_PicTable pic_table = &library->pic_table;
- FT_Memory memory = library->memory;
-
-
- if ( pic_table->autofit )
- {
- FT_FREE( pic_table->autofit );
- pic_table->autofit = NULL;
- }
- }
-
-
- FT_Error
- autofit_module_class_pic_init( FT_Library library )
- {
- FT_PicTable pic_table = &library->pic_table;
- FT_Memory memory = library->memory;
+ AFModulePIC* container = _autofit;
FT_UInt ss;
- FT_Error error = FT_Err_Ok;
- AFModulePIC* container;
-
- /* allocate pointer, clear and set global container pointer */
- if ( FT_NEW( container ) )
- return error;
-
- pic_table->autofit = container;
/* initialize pointer table - this is how the module usually expects this data */
for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
@@ -72,23 +48,31 @@
/* add call to initialization function when you add new scripts */
ss = 0;
- ft_pic_init_af_dummy_script_class(&container->af_script_classes_rec[ss++]);
+ ft_pic_init_af_dummy_script_class (&container->af_script_classes_rec[ss++]);
#ifdef FT_OPTION_AUTOFIT2
ft_pic_init_af_latin2_script_class(&container->af_script_classes_rec[ss++]);
#endif
- ft_pic_init_af_latin_script_class(&container->af_script_classes_rec[ss++]);
- ft_pic_init_af_cjk_script_class(&container->af_script_classes_rec[ss++]);
- ft_pic_init_af_indic_script_class(&container->af_script_classes_rec[ss++]);
+ ft_pic_init_af_latin_script_class (&container->af_script_classes_rec[ss++]);
+ ft_pic_init_af_cjk_script_class (&container->af_script_classes_rec[ss++]);
+ ft_pic_init_af_indic_script_class (&container->af_script_classes_rec[ss++]);
- ft_pic_init_af_autofitter_service(library, &container->af_autofitter_service);
+ ft_pic_init_af_autofitter_service(pic->library, &container->af_autofitter_service);
-/*Exit:*/
- if(error)
- autofit_module_class_pic_free(library);
- return error;
+ return 0;
}
+ FT_Error
+ autofit_module_class_pic_init( FT_Library library )
+ {
+ FT_PicTable pic = &library->pic_table;
+
+ return ft_pic_table_init_data( pic, pic->autofit,
+ sizeof(AFModulePIC),
+ pic_autofit_init,
+ NULL );
+ }
+
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/autofit/afpic.h b/src/autofit/afpic.h
index 7c546bb11..a1720bf9f 100644
--- a/src/autofit/afpic.h
+++ b/src/autofit/afpic.h
@@ -19,36 +19,35 @@
#ifndef __AFPIC_H__
#define __AFPIC_H__
-
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
-#define AF_SCRIPT_CLASSES_GET af_script_classes
-#define AF_AF_AUTOFITTER_SERVICE_GET af_autofitter_service
+# define AF_SCRIPT_CLASSES_GET af_script_classes
+# define AF_AF_AUTOFITTER_SERVICE_GET af_autofitter_service
#else /* FT_CONFIG_OPTION_PIC */
-#include "aftypes.h"
+# include "aftypes.h"
/* increase these when you add new scripts, and update autofit_module_class_pic_init */
-#ifdef FT_OPTION_AUTOFIT2
- #define AF_SCRIPT_CLASSES_COUNT 6
-#else
- #define AF_SCRIPT_CLASSES_COUNT 5
-#endif
-#define AF_SCRIPT_CLASSES_REC_COUNT (AF_SCRIPT_CLASSES_COUNT-1)
+# ifdef FT_OPTION_AUTOFIT2
+# define AF_SCRIPT_CLASSES_COUNT 6
+# else
+# define AF_SCRIPT_CLASSES_COUNT 5
+# endif
+# define AF_SCRIPT_CLASSES_REC_COUNT (AF_SCRIPT_CLASSES_COUNT-1)
typedef struct AFModulePIC_
{
- AF_ScriptClass af_script_classes[AF_SCRIPT_CLASSES_COUNT];
- AF_ScriptClassRec af_script_classes_rec[AF_SCRIPT_CLASSES_REC_COUNT];
+ AF_ScriptClass af_script_classes[AF_SCRIPT_CLASSES_COUNT];
+ AF_ScriptClassRec af_script_classes_rec[AF_SCRIPT_CLASSES_REC_COUNT];
FT_AutoHinter_ServiceRec af_autofitter_service;
} AFModulePIC;
-#define GET_PIC(lib) ((AFModulePIC*)((lib)->pic_table.autofit))
+#define GET_PIC(lib) ((AFModulePIC*)((lib)->pic_table.autofit->data))
#define AF_SCRIPT_CLASSES_GET (GET_PIC(FT_FACE_LIBRARY(globals->face))->af_script_classes)
#define AF_AF_AUTOFITTER_SERVICE_GET (GET_PIC(library)->af_autofitter_service)