Position Independent Code (PIC) support in psnames module.
* include/freetype/internal/services/svpscmap.h add macros to init instances of FT_Service_PsCMapsRec. * src/psnames/psmodule.h declare psnames_module_class using macros from ftmodapi.h, when FT_CONFIG_OPTION_PIC is defined create and destroy functions will be declared. * src/psnames/psmodule.c when FT_CONFIG_OPTION_PIC is defined pscmaps_interface and pscmaps_services structs and psnames_module_class 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 pspic.h in order to access them. New Files: * src/psnames/pspic.h declare struct to hold PIC globals for psnames module and macros to access them. * src/psnames/pspic.c implement functions to allocate, destroy and initialize PIC globals for psnames module. * src/psnames/psnames.c add new file to build: pspic.c. * src/psnames/jamfile add new files to FT2_MULTI build: pspic.c.
This commit is contained in:
parent
056095096f
commit
24b110c6c6
27
ChangeLog
27
ChangeLog
|
@ -1,3 +1,30 @@
|
|||
2009-04-05 Oran Agra <oran@monfort.co.il>
|
||||
|
||||
Position Independent Code (PIC) support in psnames module.
|
||||
|
||||
* include/freetype/internal/services/svpscmap.h add macros to init
|
||||
instances of FT_Service_PsCMapsRec.
|
||||
|
||||
* src/psnames/psmodule.h declare psnames_module_class
|
||||
using macros from ftmodapi.h,
|
||||
when FT_CONFIG_OPTION_PIC is defined create and destroy
|
||||
functions will be declared.
|
||||
* src/psnames/psmodule.c when FT_CONFIG_OPTION_PIC is defined
|
||||
pscmaps_interface and pscmaps_services structs
|
||||
and psnames_module_class 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 pspic.h in order to access them.
|
||||
|
||||
New Files:
|
||||
* src/psnames/pspic.h declare struct to hold PIC globals for psnames
|
||||
module and macros to access them.
|
||||
* src/psnames/pspic.c implement functions to allocate, destroy and
|
||||
initialize PIC globals for psnames module.
|
||||
|
||||
* src/psnames/psnames.c add new file to build: pspic.c.
|
||||
* src/psnames/jamfile add new files to FT2_MULTI build: pspic.c.
|
||||
|
||||
2009-04-05 Oran Agra <oran@monfort.co.il>
|
||||
|
||||
Position Independent Code (PIC) support in raster renderer.
|
||||
|
|
|
@ -117,6 +117,41 @@ FT_BEGIN_HEADER
|
|||
const unsigned short* adobe_expert_encoding;
|
||||
};
|
||||
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_PIC
|
||||
|
||||
#define FT_DEFINE_SERVICE_PSCMAPSREC(class_, unicode_value_, unicodes_init_, \
|
||||
unicodes_char_index_, unicodes_char_next_, macintosh_name_, \
|
||||
adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_) \
|
||||
static const FT_Service_PsCMapsRec class_ = \
|
||||
{ \
|
||||
unicode_value_, unicodes_init_, \
|
||||
unicodes_char_index_, unicodes_char_next_, macintosh_name_, \
|
||||
adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_ \
|
||||
};
|
||||
|
||||
#else /* FT_CONFIG_OPTION_PIC */
|
||||
|
||||
#define FT_DEFINE_SERVICE_PSCMAPSREC(class_, unicode_value_, unicodes_init_, \
|
||||
unicodes_char_index_, unicodes_char_next_, macintosh_name_, \
|
||||
adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_) \
|
||||
void \
|
||||
FT_Init_Class_##class_( FT_Library library, \
|
||||
FT_Service_PsCMapsRec* clazz) \
|
||||
{ \
|
||||
FT_UNUSED(library); \
|
||||
clazz->unicode_value = unicode_value_; \
|
||||
clazz->unicodes_init = unicodes_init_; \
|
||||
clazz->unicodes_char_index = unicodes_char_index_; \
|
||||
clazz->unicodes_char_next = unicodes_char_next_; \
|
||||
clazz->macintosh_name = macintosh_name_; \
|
||||
clazz->adobe_std_strings = adobe_std_strings_; \
|
||||
clazz->adobe_std_encoding = adobe_std_encoding_; \
|
||||
clazz->adobe_expert_encoding = adobe_expert_encoding_; \
|
||||
}
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_PIC */
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ SubDir FT2_TOP $(FT2_SRC_DIR) psnames ;
|
|||
|
||||
if $(FT2_MULTI)
|
||||
{
|
||||
_sources = psmodule ;
|
||||
_sources = psmodule pspic ;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "pstables.h"
|
||||
|
||||
#include "psnamerr.h"
|
||||
#include "pspic.h"
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
|
@ -516,56 +517,66 @@
|
|||
}
|
||||
|
||||
|
||||
static
|
||||
const FT_Service_PsCMapsRec pscmaps_interface =
|
||||
{
|
||||
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
|
||||
|
||||
FT_DEFINE_SERVICE_PSCMAPSREC(pscmaps_interface,
|
||||
(PS_Unicode_ValueFunc) ps_unicode_value,
|
||||
(PS_Unicodes_InitFunc) ps_unicodes_init,
|
||||
(PS_Unicodes_CharIndexFunc)ps_unicodes_char_index,
|
||||
(PS_Unicodes_CharNextFunc) ps_unicodes_char_next,
|
||||
|
||||
#else
|
||||
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
|
||||
|
||||
(PS_Macintosh_NameFunc) ps_get_macintosh_name,
|
||||
(PS_Adobe_Std_StringsFunc) ps_get_standard_strings,
|
||||
|
||||
t1_standard_encoding,
|
||||
t1_expert_encoding
|
||||
};
|
||||
)
|
||||
|
||||
#else
|
||||
|
||||
FT_DEFINE_SERVICE_PSCMAPSREC(pscmaps_interface,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
(PS_Macintosh_NameFunc) ps_get_macintosh_name,
|
||||
(PS_Adobe_Std_StringsFunc) ps_get_standard_strings,
|
||||
|
||||
t1_standard_encoding,
|
||||
t1_expert_encoding
|
||||
)
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
|
||||
|
||||
|
||||
FT_DEFINE_SERVICEDESCREC1(pscmaps_services,
|
||||
FT_SERVICE_ID_POSTSCRIPT_CMAPS, &FT_PSCMAPS_INTERFACE_GET
|
||||
)
|
||||
|
||||
|
||||
static const FT_ServiceDescRec pscmaps_services[] =
|
||||
{
|
||||
{ FT_SERVICE_ID_POSTSCRIPT_CMAPS, &pscmaps_interface },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
static FT_Pointer
|
||||
psnames_get_service( FT_Module module,
|
||||
const char* service_id )
|
||||
{
|
||||
FT_UNUSED( module );
|
||||
FT_Library library = module->library;
|
||||
FT_UNUSED(library);
|
||||
|
||||
return ft_service_list_lookup( pscmaps_services, service_id );
|
||||
return ft_service_list_lookup( FT_PSCMAPS_SERVICES_GET, service_id );
|
||||
}
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
|
||||
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
#define PUT_PS_NAMES_SERVICE(a) 0
|
||||
#else
|
||||
#define PUT_PS_NAMES_SERVICE(a) a
|
||||
#endif
|
||||
|
||||
FT_CALLBACK_TABLE_DEF
|
||||
const FT_Module_Class psnames_module_class =
|
||||
{
|
||||
FT_DEFINE_MODULE(psnames_module_class,
|
||||
|
||||
0, /* this is not a font driver, nor a renderer */
|
||||
sizeof ( FT_ModuleRec ),
|
||||
|
||||
|
@ -573,18 +584,12 @@
|
|||
0x10000L, /* driver version */
|
||||
0x20000L, /* driver requires FreeType 2 or above */
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
0,
|
||||
PUT_PS_NAMES_SERVICE((void*)&FT_PSCMAPS_INTERFACE_GET), /* module specific interface */
|
||||
(FT_Module_Constructor)0,
|
||||
(FT_Module_Destructor) 0,
|
||||
(FT_Module_Requester) 0
|
||||
#else
|
||||
(void*)&pscmaps_interface, /* module specific interface */
|
||||
(FT_Module_Constructor)0,
|
||||
(FT_Module_Destructor) 0,
|
||||
(FT_Module_Requester) psnames_get_service
|
||||
#endif
|
||||
};
|
||||
(FT_Module_Requester) PUT_PS_NAMES_SERVICE(psnames_get_service)
|
||||
)
|
||||
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
FT_EXPORT_VAR( const FT_Module_Class ) psnames_module_class;
|
||||
FT_DECLARE_MODULE( psnames_module_class )
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
|
||||
#include <ft2build.h>
|
||||
#include "pspic.c"
|
||||
#include "psmodule.c"
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
/***************************************************************************/
|
||||
/* */
|
||||
/* pspic.c */
|
||||
/* */
|
||||
/* The FreeType position independent code services for psnames 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 "pspic.h"
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_PIC
|
||||
|
||||
/* forward declaration of PIC init functions from psmodule.c */
|
||||
FT_Error FT_Create_Class_pscmaps_services( FT_Library, FT_ServiceDescRec**);
|
||||
void FT_Destroy_Class_pscmaps_services( FT_Library, FT_ServiceDescRec*);
|
||||
void FT_Init_Class_pscmaps_interface( FT_Library, FT_Service_PsCMapsRec*);
|
||||
|
||||
void
|
||||
psnames_module_class_pic_free( FT_Library library )
|
||||
{
|
||||
FT_PIC_Container* pic_container = &library->pic_container;
|
||||
FT_Memory memory = library->memory;
|
||||
if ( pic_container->psnames )
|
||||
{
|
||||
PSModulePIC* container = (PSModulePIC*)pic_container->psnames;
|
||||
if(container->pscmaps_services)
|
||||
FT_Destroy_Class_pscmaps_services(library, container->pscmaps_services);
|
||||
container->pscmaps_services = NULL;
|
||||
FT_FREE( container );
|
||||
pic_container->psnames = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
FT_Error
|
||||
psnames_module_class_pic_init( FT_Library library )
|
||||
{
|
||||
FT_PIC_Container* pic_container = &library->pic_container;
|
||||
FT_Error error = FT_Err_Ok;
|
||||
PSModulePIC* 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->psnames = container;
|
||||
|
||||
/* initialize pointer table - this is how the module usually expects this data */
|
||||
error = FT_Create_Class_pscmaps_services(library, &container->pscmaps_services);
|
||||
if(error)
|
||||
goto Exit;
|
||||
FT_Init_Class_pscmaps_interface(library, &container->pscmaps_interface);
|
||||
|
||||
Exit:
|
||||
if(error)
|
||||
psnames_module_class_pic_free(library);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_PIC */
|
||||
|
||||
|
||||
/* END */
|
|
@ -0,0 +1,54 @@
|
|||
/***************************************************************************/
|
||||
/* */
|
||||
/* pspic.h */
|
||||
/* */
|
||||
/* The FreeType position independent code services for psnames 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 __PSPIC_H__
|
||||
#define __PSPIC_H__
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
#include FT_INTERNAL_PIC_H
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_PIC
|
||||
#define FT_PSCMAPS_SERVICES_GET pscmaps_services
|
||||
#define FT_PSCMAPS_INTERFACE_GET pscmaps_interface
|
||||
|
||||
#else /* FT_CONFIG_OPTION_PIC */
|
||||
|
||||
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
|
||||
|
||||
typedef struct PSModulePIC_
|
||||
{
|
||||
FT_ServiceDescRec* pscmaps_services;
|
||||
FT_Service_PsCMapsRec pscmaps_interface;
|
||||
} PSModulePIC;
|
||||
|
||||
#define GET_PIC(lib) ((PSModulePIC*)((lib)->pic_container.psnames))
|
||||
#define FT_PSCMAPS_SERVICES_GET (GET_PIC(library)->pscmaps_services)
|
||||
#define FT_PSCMAPS_INTERFACE_GET (GET_PIC(library)->pscmaps_interface)
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_PIC */
|
||||
|
||||
/* */
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* __PSPIC_H__ */
|
||||
|
||||
|
||||
/* END */
|
Loading…
Reference in New Issue