convert autofit module to FT_PicData

This commit is contained in:
David Turner 2009-04-13 00:33:12 +02:00
parent 929ff6996c
commit 329d42d9eb
3 changed files with 33 additions and 50 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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)