Position Independent Code (PIC) support in cff driver.

* include/freetype/internal/services/svcid.h add macros to init
instances of FT_Service_CIDRec.
* include/freetype/internal/services/svpsinfo.h add macros to init
instances of FT_Service_PsInfoRec.

* src/cff/cffcmap.h declare cff_cmap_encoding_class_rec
and cff_cmap_unicode_class_rec using macros from
ftobjs.h, when FT_CONFIG_OPTION_PIC is defined create and destroy
functions will be declared.
* src/cff/cffcmap.c when FT_CONFIG_OPTION_PIC is defined
the following structs:
cff_cmap_encoding_class_rec and cff_cmap_unicode_class_rec
will have functions to init or create and destroy them
instead of being allocated in the global scope.

* src/cff/cffdrivr.h declare cff_driver_class using macros from
ftdriver.h, when FT_CONFIG_OPTION_PIC is defined create and destroy
functions will be declared.
* src/cff/cffdrivr.c when FT_CONFIG_OPTION_PIC is defined
the following structs:
cff_service_glyph_dict, cff_service_ps_info, cff_service_ps_name
cff_service_get_cmap_info, cff_service_cid_info, cff_driver_class,
and cff_services array
will have functions to init or create and destroy them
instead of being allocated in the global scope.
And macros will be used from cffpic.h in order to access them
from the pic_container.
Use macros from cffpic.h in order to access the
structs allocated in cffcmap.c

* src/cff/cffobjs.c Use macros from cffpic.h in order to access the
structs allocated in cffcmap.c

* src/cff/parser.c when FT_CONFIG_OPTION_PIC is defined
implement functions to create and destroy cff_field_handlers array
instead of being allocated in the global scope.
And macros will be used from cffpic.h in order to access it
from the pic_container.

New Files:
* src/cff/cffpic.h declare struct to hold PIC globals for cff
driver and macros to access them.
* src/cff/cffpic.c implement functions to allocate, destroy and
initialize PIC globals for cff driver.

* src/cff/cff.c add new file to build: cffpic.c.
* src/cff/jamfile add new files to FT2_MULTI build: cffpic.c.
This commit is contained in:
Oran Agra 2009-04-05 18:12:03 +03:00
parent fb429ec409
commit cb3b61416b
13 changed files with 439 additions and 75 deletions

View File

@ -1,3 +1,55 @@
2009-04-05 Oran Agra <oran@monfort.co.il>
Position Independent Code (PIC) support in cff driver.
* include/freetype/internal/services/svcid.h add macros to init
instances of FT_Service_CIDRec.
* include/freetype/internal/services/svpsinfo.h add macros to init
instances of FT_Service_PsInfoRec.
* src/cff/cffcmap.h declare cff_cmap_encoding_class_rec
and cff_cmap_unicode_class_rec using macros from
ftobjs.h, when FT_CONFIG_OPTION_PIC is defined create and destroy
functions will be declared.
* src/cff/cffcmap.c when FT_CONFIG_OPTION_PIC is defined
the following structs:
cff_cmap_encoding_class_rec and cff_cmap_unicode_class_rec
will have functions to init or create and destroy them
instead of being allocated in the global scope.
* src/cff/cffdrivr.h declare cff_driver_class using macros from
ftdriver.h, when FT_CONFIG_OPTION_PIC is defined create and destroy
functions will be declared.
* src/cff/cffdrivr.c when FT_CONFIG_OPTION_PIC is defined
the following structs:
cff_service_glyph_dict, cff_service_ps_info, cff_service_ps_name
cff_service_get_cmap_info, cff_service_cid_info, cff_driver_class,
and cff_services array
will have functions to init or create and destroy them
instead of being allocated in the global scope.
And macros will be used from cffpic.h in order to access them
from the pic_container.
Use macros from cffpic.h in order to access the
structs allocated in cffcmap.c
* src/cff/cffobjs.c Use macros from cffpic.h in order to access the
structs allocated in cffcmap.c
* src/cff/parser.c when FT_CONFIG_OPTION_PIC is defined
implement functions to create and destroy cff_field_handlers array
instead of being allocated in the global scope.
And macros will be used from cffpic.h in order to access it
from the pic_container.
New Files:
* src/cff/cffpic.h declare struct to hold PIC globals for cff
driver and macros to access them.
* src/cff/cffpic.c implement functions to allocate, destroy and
initialize PIC globals for cff driver.
* src/cff/cff.c add new file to build: cffpic.c.
* src/cff/jamfile add new files to FT2_MULTI build: cffpic.c.
2009-04-05 Oran Agra <oran@monfort.co.il>
Position Independent Code (PIC) support in sfnt driver.

View File

@ -46,6 +46,31 @@ FT_BEGIN_HEADER
FT_CID_GetCIDFromGlyphIndexFunc get_cid_from_glyph_index;
};
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_CIDREC(class_, get_ros_, \
get_is_cid_, get_cid_from_glyph_index_ ) \
static const FT_Service_CIDRec class_ = \
{ \
get_ros_, get_is_cid_, get_cid_from_glyph_index_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_CIDREC(class_, get_ros_, \
get_is_cid_, get_cid_from_glyph_index_ ) \
void \
FT_Init_Class_##class_( FT_Library library, \
FT_Service_CIDRec* clazz) \
{ \
FT_UNUSED(library); \
clazz->get_ros = get_ros_; \
clazz->get_is_cid = get_is_cid_; \
clazz->get_cid_from_glyph_index = get_cid_from_glyph_index_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */

View File

@ -53,6 +53,33 @@ FT_BEGIN_HEADER
PS_GetFontPrivateFunc ps_get_font_private;
};
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_PSINFOREC(class_, get_font_info_, \
ps_get_font_extra_, has_glyph_names_, get_font_private_) \
static const FT_Service_PsInfoRec class_ = \
{ \
get_font_info_, ps_get_font_extra_, has_glyph_names_, \
get_font_private_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_PSINFOREC(class_, get_font_info_, \
ps_get_font_extra_, has_glyph_names_, get_font_private_) \
void \
FT_Init_Class_##class_( FT_Library library, \
FT_Service_PsInfoRec* clazz) \
{ \
FT_UNUSED(library); \
clazz->ps_get_font_info = get_font_info_; \
clazz->ps_get_font_extra = ps_get_font_extra_; \
clazz->ps_has_glyph_names = has_glyph_names_; \
clazz->ps_get_font_private = get_font_private_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */

View File

@ -16,7 +16,7 @@ SubDir FT2_TOP $(FT2_SRC_DIR) cff ;
if $(FT2_MULTI)
{
_sources = cffdrivr cffgload cffload cffobjs cffparse cffcmap ;
_sources = cffdrivr cffgload cffload cffobjs cffparse cffcmap cffpic ;
}
else
{

View File

@ -19,6 +19,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
#include "cffpic.c"
#include "cffdrivr.c"
#include "cffparse.c"
#include "cffload.c"

View File

@ -99,9 +99,7 @@
}
FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
cff_cmap_encoding_class_rec =
{
FT_DEFINE_CMAP_CLASS(cff_cmap_encoding_class_rec,
sizeof ( CFF_CMapStdRec ),
(FT_CMap_InitFunc) cff_cmap_encoding_init,
@ -110,7 +108,7 @@
(FT_CMap_CharNextFunc) cff_cmap_encoding_char_next,
NULL, NULL, NULL, NULL, NULL
};
)
/*************************************************************************/
@ -207,9 +205,7 @@
}
FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
cff_cmap_unicode_class_rec =
{
FT_DEFINE_CMAP_CLASS(cff_cmap_unicode_class_rec,
sizeof ( PS_UnicodesRec ),
(FT_CMap_InitFunc) cff_cmap_unicode_init,
@ -218,7 +214,6 @@
(FT_CMap_CharNextFunc) cff_cmap_unicode_char_next,
NULL, NULL, NULL, NULL, NULL
};
)
/* END */

View File

@ -43,8 +43,7 @@ FT_BEGIN_HEADER
} CFF_CMapStdRec;
FT_CALLBACK_TABLE const FT_CMap_ClassRec
cff_cmap_encoding_class_rec;
FT_DECLARE_CMAP_CLASS(cff_cmap_encoding_class_rec)
/*************************************************************************/
@ -57,8 +56,7 @@ FT_BEGIN_HEADER
/* unicode (synthetic) cmaps */
FT_CALLBACK_TABLE const FT_CMap_ClassRec
cff_cmap_unicode_class_rec;
FT_DECLARE_CMAP_CLASS(cff_cmap_unicode_class_rec)
FT_END_HEADER

View File

@ -31,8 +31,10 @@
#include "cffgload.h"
#include "cffload.h"
#include "cffcmap.h"
#include "cffparse.h"
#include "cfferrs.h"
#include "cffpic.h"
#include FT_SERVICE_XFREE86_NAME_H
#include FT_SERVICE_GLYPH_DICT_H
@ -308,11 +310,10 @@
}
static const FT_Service_GlyphDictRec cff_service_glyph_dict =
{
FT_DEFINE_SERVICE_GLYPHDICTREC(cff_service_glyph_dict,
(FT_GlyphDict_GetNameFunc) cff_get_glyph_name,
(FT_GlyphDict_NameIndexFunc)cff_get_name_index,
};
(FT_GlyphDict_NameIndexFunc)cff_get_name_index
)
/*
@ -377,13 +378,12 @@
}
static const FT_Service_PsInfoRec cff_service_ps_info =
{
FT_DEFINE_SERVICE_PSINFOREC(cff_service_ps_info,
(PS_GetFontInfoFunc) cff_ps_get_font_info,
(PS_GetFontExtraFunc) NULL,
(PS_HasGlyphNamesFunc) cff_ps_has_glyph_names,
(PS_GetFontPrivateFunc)NULL /* unsupported with CFF fonts */
};
)
/*
@ -401,10 +401,9 @@
}
static const FT_Service_PsFontNameRec cff_service_ps_name =
{
FT_DEFINE_SERVICE_PSFONTNAMEREC(cff_service_ps_name,
(FT_PsName_GetFunc)cff_get_ps_name
};
)
/*
@ -423,16 +422,16 @@
{
FT_CMap cmap = FT_CMAP( charmap );
FT_Error error = CFF_Err_Ok;
FT_Face face = FT_CMAP_FACE( cmap );
FT_Library library = FT_FACE_LIBRARY( face );
cmap_info->language = 0;
cmap_info->format = 0;
if ( cmap->clazz != &cff_cmap_encoding_class_rec &&
cmap->clazz != &cff_cmap_unicode_class_rec )
if ( cmap->clazz != &FT_CFF_CMAP_ENCODING_CLASS_REC_GET &&
cmap->clazz != &FT_CFF_CMAP_UNICODE_CLASS_REC_GET )
{
FT_Face face = FT_CMAP_FACE( cmap );
FT_Library library = FT_FACE_LIBRARY( face );
FT_Module sfnt = FT_Get_Module( library, "sfnt" );
FT_Service_TTCMaps service =
(FT_Service_TTCMaps)ft_module_get_service( sfnt,
@ -447,10 +446,9 @@
}
static const FT_Service_TTCMapsRec cff_service_get_cmap_info =
{
FT_DEFINE_SERVICE_TTCMAPSREC(cff_service_get_cmap_info,
(TT_CMap_Info_GetFunc)cff_get_cmap_info
};
)
/*
@ -569,12 +567,11 @@
}
static const FT_Service_CIDRec cff_service_cid_info =
{
FT_DEFINE_SERVICE_CIDREC(cff_service_cid_info,
(FT_CID_GetRegistryOrderingSupplementFunc)cff_get_ros,
(FT_CID_GetIsInternallyCIDKeyedFunc) cff_get_is_cid,
(FT_CID_GetCIDFromGlyphIndexFunc) cff_get_cid_from_glyph_index
};
)
/*************************************************************************/
@ -588,20 +585,24 @@
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
static const FT_ServiceDescRec cff_services[] =
{
{ FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF },
{ FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info },
{ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name },
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
{ FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict },
FT_DEFINE_SERVICEDESCREC6(cff_services,
FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF,
FT_SERVICE_ID_POSTSCRIPT_INFO, &FT_CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_GLYPH_DICT, &FT_CFF_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &FT_CFF_SERVICE_CID_INFO_GET
)
#else
FT_DEFINE_SERVICEDESCREC5(cff_services,
FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF,
FT_SERVICE_ID_POSTSCRIPT_INFO, &FT_CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &FT_CFF_SERVICE_CID_INFO_GET
)
#endif
{ FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info },
{ FT_SERVICE_ID_CID, &cff_service_cid_info },
{ NULL, NULL }
};
FT_CALLBACK_DEF( FT_Module_Interface )
cff_get_interface( FT_Module driver, /* CFF_Driver */
@ -609,9 +610,11 @@
{
FT_Module sfnt;
FT_Module_Interface result;
FT_Library library = driver->library;
FT_UNUSED(library);
result = ft_service_list_lookup( cff_services, module_interface );
result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface );
if ( result != NULL )
return result;
@ -624,11 +627,13 @@
/* The FT_DriverInterface structure is defined in ftdriver.h. */
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec cff_driver_class =
{
/* begin with the FT_Module_Class fields */
{
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#define CFF_SIZE_SELECT cff_size_select
#else
#define CFF_SIZE_SELECT 0
#endif
FT_DEFINE_DRIVER(cff_driver_class,
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
@ -643,7 +648,6 @@
cff_driver_init,
cff_driver_done,
cff_get_interface,
},
/* now the specific driver fields */
sizeof( TT_FaceRec ),
@ -657,10 +661,8 @@
cff_slot_init,
cff_slot_done,
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
ft_stub_set_char_sizes,
ft_stub_set_pixel_sizes,
#endif
ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
Load_Glyph,
@ -670,12 +672,8 @@
cff_size_request,
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
cff_size_select
#else
0 /* FT_Size_SelectFunc */
#endif
};
CFF_SIZE_SELECT
)
/* END */

View File

@ -27,8 +27,7 @@
FT_BEGIN_HEADER
FT_CALLBACK_TABLE
const FT_Driver_ClassRec cff_driver_class;
FT_DECLARE_DRIVER( cff_driver_class )
FT_END_HEADER

View File

@ -30,6 +30,7 @@
#include "cffload.h"
#include "cffcmap.h"
#include "cfferrs.h"
#include "cffpic.h"
/*************************************************************************/
@ -869,7 +870,7 @@
nn = (FT_UInt)cffface->num_charmaps;
FT_CMap_New( &cff_cmap_unicode_class_rec, NULL, &cmaprec, NULL );
FT_CMap_New( &FT_CFF_CMAP_UNICODE_CLASS_REC_GET, NULL, &cmaprec, NULL );
/* if no Unicode charmap was previously selected, select this one */
if ( cffface->charmap == NULL && nn != (FT_UInt)cffface->num_charmaps )
@ -888,19 +889,19 @@
{
cmaprec.encoding_id = TT_ADOBE_ID_STANDARD;
cmaprec.encoding = FT_ENCODING_ADOBE_STANDARD;
clazz = &cff_cmap_encoding_class_rec;
clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
}
else if ( encoding->offset == 1 )
{
cmaprec.encoding_id = TT_ADOBE_ID_EXPERT;
cmaprec.encoding = FT_ENCODING_ADOBE_EXPERT;
clazz = &cff_cmap_encoding_class_rec;
clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
}
else
{
cmaprec.encoding_id = TT_ADOBE_ID_CUSTOM;
cmaprec.encoding = FT_ENCODING_ADOBE_CUSTOM;
clazz = &cff_cmap_encoding_class_rec;
clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
}
FT_CMap_New( clazz, NULL, &cmaprec, NULL );

View File

@ -22,6 +22,7 @@
#include FT_INTERNAL_DEBUG_H
#include "cfferrs.h"
#include "cffpic.h"
/*************************************************************************/
@ -572,6 +573,11 @@
#define CFF_FIELD_DELTA( code, name, max ) \
CFF_FIELD( code, name, cff_kind_delta )
#define CFFCODE_TOPDICT 0x1000
#define CFFCODE_PRIVATE 0x2000
#ifndef FT_CONFIG_OPTION_PIC
#define CFF_FIELD_CALLBACK( code, name ) \
{ \
cff_kind_callback, \
@ -603,9 +609,6 @@
FT_FIELD_OFFSET( num_ ## name ) \
},
#define CFFCODE_TOPDICT 0x1000
#define CFFCODE_PRIVATE 0x2000
static const CFF_Field_Handler cff_field_handlers[] =
{
@ -615,13 +618,99 @@
};
#else /* FT_CONFIG_OPTION_PIC */
void FT_Destroy_Class_cff_field_handlers(FT_Library library, CFF_Field_Handler* clazz)
{
FT_Memory memory = library->memory;
if ( clazz )
FT_FREE( clazz );
}
FT_Error FT_Create_Class_cff_field_handlers(FT_Library library, CFF_Field_Handler** output_class)
{
CFF_Field_Handler* clazz;
FT_Error error;
FT_Memory memory = library->memory;
int i=0;
#undef CFF_FIELD
#undef CFF_FIELD_DELTA
#undef CFF_FIELD_CALLBACK
#define CFF_FIELD_CALLBACK( code, name ) i++;
#define CFF_FIELD( code, name, kind ) i++;
#define CFF_FIELD_DELTA( code, name, max ) i++;
#include "cfftoken.h"
i++;/*{ 0, 0, 0, 0, 0, 0, 0 }*/
if ( FT_ALLOC( clazz, sizeof(CFF_Field_Handler)*i ) )
return error;
i=0;
#undef CFF_FIELD
#undef CFF_FIELD_DELTA
#undef CFF_FIELD_CALLBACK
#define CFF_FIELD_CALLBACK( code_, name_ ) \
clazz[i].kind = cff_kind_callback; \
clazz[i].code = code_ | CFFCODE; \
clazz[i].offset = 0; \
clazz[i].size = 0; \
clazz[i].reader = cff_parse_ ## name_; \
clazz[i].array_max = 0; \
clazz[i].count_offset = 0; \
i++;
#undef CFF_FIELD
#define CFF_FIELD( code_, name_, kind_ ) \
clazz[i].kind = kind_; \
clazz[i].code = code_ | CFFCODE; \
clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
clazz[i].size = FT_FIELD_SIZE( name_ ); \
clazz[i].reader = 0; \
clazz[i].array_max = 0; \
clazz[i].count_offset = 0; \
i++; \
#undef CFF_FIELD_DELTA
#define CFF_FIELD_DELTA( code_, name_, max_ ) \
clazz[i].kind = cff_kind_delta; \
clazz[i].code = code_ | CFFCODE; \
clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \
clazz[i].reader = 0; \
clazz[i].array_max = max_; \
clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
i++;
#include "cfftoken.h"
clazz[i].kind = 0;
clazz[i].code = 0;
clazz[i].offset = 0;
clazz[i].size = 0;
clazz[i].reader = 0;
clazz[i].array_max = 0;
clazz[i].count_offset = 0;
*output_class = clazz;
return FT_Err_Ok;
}
#endif /* FT_CONFIG_OPTION_PIC */
FT_LOCAL_DEF( FT_Error )
cff_parser_run( CFF_Parser parser,
FT_Byte* start,
FT_Byte* limit )
{
FT_Byte* p = start;
FT_Error error = CFF_Err_Ok;
FT_Byte* p = start;
FT_Error error = CFF_Err_Ok;
FT_Library library = parser->library;
FT_UNUSED(library);
parser->top = parser->stack;
@ -691,7 +780,7 @@
}
code = code | parser->object_code;
for ( field = cff_field_handlers; field->kind; field++ )
for ( field = FT_CFF_FIELD_HANDLERS_GET; field->kind; field++ )
{
if ( field->code == (FT_Int)code )
{

99
src/cff/cffpic.c Normal file
View File

@ -0,0 +1,99 @@
/***************************************************************************/
/* */
/* cffpic.c */
/* */
/* The FreeType position independent code services for cff module. */
/* */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "cffpic.h"
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from cffdrivr.c */
FT_Error FT_Create_Class_cff_services( FT_Library, FT_ServiceDescRec**);
void FT_Destroy_Class_cff_services( FT_Library, FT_ServiceDescRec*);
void FT_Init_Class_cff_service_ps_info( FT_Library, FT_Service_PsInfoRec*);
void FT_Init_Class_cff_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
void FT_Init_Class_cff_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
void FT_Init_Class_cff_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
void FT_Init_Class_cff_service_cid_info( FT_Library, FT_Service_CIDRec*);
/* forward declaration of PIC init functions from cffparse.c */
FT_Error FT_Create_Class_cff_field_handlers( FT_Library, CFF_Field_Handler**);
void FT_Destroy_Class_cff_field_handlers( FT_Library, CFF_Field_Handler*);
/* forward declaration of PIC init functions from cffcmap.c */
void FT_Init_Class_cff_cmap_encoding_class_rec( FT_Library, FT_CMap_ClassRec*);
void FT_Init_Class_cff_cmap_unicode_class_rec( FT_Library, FT_CMap_ClassRec*);
void
cff_driver_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->cff )
{
CffModulePIC* container = (CffModulePIC*)pic_container->cff;
if(container->cff_services)
FT_Destroy_Class_cff_services(library, container->cff_services);
container->cff_services = NULL;
if(container->cff_field_handlers)
FT_Destroy_Class_cff_field_handlers(library, container->cff_field_handlers);
container->cff_field_handlers = NULL;
FT_FREE( container );
pic_container->cff = NULL;
}
}
FT_Error
cff_driver_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
CffModulePIC* container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
pic_container->cff = container;
/* initialize pointer table - this is how the module usually expects this data */
error = FT_Create_Class_cff_services(library, &container->cff_services);
if(error)
goto Exit;
error = FT_Create_Class_cff_field_handlers(library, &container->cff_field_handlers);
if(error)
goto Exit;
FT_Init_Class_cff_service_ps_info(library, &container->cff_service_ps_info);
FT_Init_Class_cff_service_glyph_dict(library, &container->cff_service_glyph_dict);
FT_Init_Class_cff_service_ps_name(library, &container->cff_service_ps_name);
FT_Init_Class_cff_service_get_cmap_info(library, &container->cff_service_get_cmap_info);
FT_Init_Class_cff_service_cid_info(library, &container->cff_service_cid_info);
FT_Init_Class_cff_cmap_encoding_class_rec(library, &container->cff_cmap_encoding_class_rec);
FT_Init_Class_cff_cmap_unicode_class_rec(library, &container->cff_cmap_unicode_class_rec);
Exit:
if(error)
cff_driver_class_pic_free(library);
return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */

80
src/cff/cffpic.h Normal file
View File

@ -0,0 +1,80 @@
/***************************************************************************/
/* */
/* cffpic.h */
/* */
/* The FreeType position independent code services for cff module. */
/* */
/* 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. */
/* */
/***************************************************************************/
#ifndef __CFFPIC_H__
#define __CFFPIC_H__
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
#define FT_CFF_SERVICE_PS_INFO_GET cff_service_ps_info
#define FT_CFF_SERVICE_GLYPH_DICT_GET cff_service_glyph_dict
#define FT_CFF_SERVICE_PS_NAME_GET cff_service_ps_name
#define FT_CFF_SERVICE_GET_CMAP_INFO_GET cff_service_get_cmap_info
#define FT_CFF_SERVICE_CID_INFO_GET cff_service_cid_info
#define FT_CFF_SERVICES_GET cff_services
#define FT_CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec
#define FT_CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec
#define FT_CFF_FIELD_HANDLERS_GET cff_field_handlers
#else /* FT_CONFIG_OPTION_PIC */
#include FT_SERVICE_GLYPH_DICT_H
#include "cffparse.h"
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_TT_CMAP_H
#include FT_SERVICE_CID_H
typedef struct CffModulePIC_
{
FT_ServiceDescRec* cff_services;
CFF_Field_Handler* cff_field_handlers;
FT_Service_PsInfoRec cff_service_ps_info;
FT_Service_GlyphDictRec cff_service_glyph_dict;
FT_Service_PsFontNameRec cff_service_ps_name;
FT_Service_TTCMapsRec cff_service_get_cmap_info;
FT_Service_CIDRec cff_service_cid_info;
FT_CMap_ClassRec cff_cmap_encoding_class_rec;
FT_CMap_ClassRec cff_cmap_unicode_class_rec;
} CffModulePIC;
#define GET_PIC(lib) ((CffModulePIC*)((lib)->pic_container.cff))
#define FT_CFF_SERVICE_PS_INFO_GET (GET_PIC(library)->cff_service_ps_info)
#define FT_CFF_SERVICE_GLYPH_DICT_GET (GET_PIC(library)->cff_service_glyph_dict)
#define FT_CFF_SERVICE_PS_NAME_GET (GET_PIC(library)->cff_service_ps_name)
#define FT_CFF_SERVICE_GET_CMAP_INFO_GET (GET_PIC(library)->cff_service_get_cmap_info)
#define FT_CFF_SERVICE_CID_INFO_GET (GET_PIC(library)->cff_service_cid_info)
#define FT_CFF_SERVICES_GET (GET_PIC(library)->cff_services)
#define FT_CFF_CMAP_ENCODING_CLASS_REC_GET (GET_PIC(library)->cff_cmap_encoding_class_rec)
#define FT_CFF_CMAP_UNICODE_CLASS_REC_GET (GET_PIC(library)->cff_cmap_unicode_class_rec)
#define FT_CFF_FIELD_HANDLERS_GET (GET_PIC(library)->cff_field_handlers)
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* __CFFPIC_H__ */
/* END */