summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog26
-rw-r--r--include/freetype/internal/pshints.h24
-rw-r--r--src/pshinter/Jamfile2
-rw-r--r--src/pshinter/pshinter.c1
-rw-r--r--src/pshinter/pshmod.c17
-rw-r--r--src/pshinter/pshmod.h2
-rw-r--r--src/pshinter/pshpic.c67
-rw-r--r--src/pshinter/pshpic.h53
8 files changed, 180 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 1336dec15..4ac7e5acf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
2009-04-05 Oran Agra <oran@monfort.co.il>
+ Position Independent Code (PIC) support in pshinter module.
+
+ * include/freetype/internal/pshints.h add macros to init
+ instances of PSHinter_Interface.
+
+ * src/pshinter/pshmod.h declare pshinter_module_class
+ using macros from ftmodapi.h,
+ when FT_CONFIG_OPTION_PIC is defined create and destroy
+ functions will be declared.
+ * src/pshinter/pshmod.c when FT_CONFIG_OPTION_PIC is defined
+ pshinter_interface and pshinter_module_class structs
+ will have functions to init or create and destroy them
+ instead of being allocated in the global scope.
+ And macros will be used from pshpic.h in order to access them.
+
+ New Files:
+ * src/pshinter/pshpic.h declare struct to hold PIC globals for pshinter
+ module and macros to access them.
+ * src/pshinter/pshpic.c implement functions to allocate, destroy and
+ initialize PIC globals for pshinter module.
+
+ * src/pshinter/pshinter.c add new file to build: pshpic.c.
+ * src/pshinter/jamfile add new files to FT2_MULTI build: pshpic.c.
+
+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
diff --git a/include/freetype/internal/pshints.h b/include/freetype/internal/pshints.h
index 48452c0cf..4ad3ac5fa 100644
--- a/include/freetype/internal/pshints.h
+++ b/include/freetype/internal/pshints.h
@@ -678,6 +678,30 @@ FT_BEGIN_HEADER
typedef PSHinter_Interface* PSHinter_Service;
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FT_DEFINE_PSHINTER_INTERFACE(class_, get_globals_funcs_, \
+ get_t1_funcs_, get_t2_funcs_) \
+ static const PSHinter_Interface class_ = \
+ { \
+ get_globals_funcs_, get_t1_funcs_, get_t2_funcs_ \
+ };
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DEFINE_PSHINTER_INTERFACE(class_, get_globals_funcs_, \
+ get_t1_funcs_, get_t2_funcs_) \
+ void \
+ FT_Init_Class_##class_( FT_Library library, \
+ PSHinter_Interface* clazz) \
+ { \
+ FT_UNUSED(library); \
+ clazz->get_globals_funcs = get_globals_funcs_; \
+ clazz->get_t1_funcs = get_t1_funcs_; \
+ clazz->get_t2_funcs = get_t2_funcs_; \
+ }
+
+#endif /* FT_CONFIG_OPTION_PIC */
FT_END_HEADER
diff --git a/src/pshinter/Jamfile b/src/pshinter/Jamfile
index 769dcc4b2..779f1b0b8 100644
--- a/src/pshinter/Jamfile
+++ b/src/pshinter/Jamfile
@@ -16,7 +16,7 @@ SubDir FT2_TOP $(FT2_SRC_DIR) pshinter ;
if $(FT2_MULTI)
{
- _sources = pshrec pshglob pshalgo pshmod ;
+ _sources = pshrec pshglob pshalgo pshmod pshpic ;
}
else
{
diff --git a/src/pshinter/pshinter.c b/src/pshinter/pshinter.c
index 8e3f19309..b35a2a91c 100644
--- a/src/pshinter/pshinter.c
+++ b/src/pshinter/pshinter.c
@@ -19,6 +19,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
+#include "pshpic.c"
#include "pshrec.c"
#include "pshglob.c"
#include "pshalgo.c"
diff --git a/src/pshinter/pshmod.c b/src/pshinter/pshmod.c
index 4eb3d9127..91da5d7e6 100644
--- a/src/pshinter/pshmod.c
+++ b/src/pshinter/pshmod.c
@@ -20,6 +20,7 @@
#include FT_INTERNAL_OBJECTS_H
#include "pshrec.h"
#include "pshalgo.h"
+#include "pshpic.h"
/* the Postscript Hinter module structure */
@@ -92,30 +93,26 @@
}
- static
- const PSHinter_Interface pshinter_interface =
- {
+ FT_DEFINE_PSHINTER_INTERFACE(pshinter_interface,
pshinter_get_globals_funcs,
pshinter_get_t1_funcs,
pshinter_get_t2_funcs
- };
+ )
- FT_CALLBACK_TABLE_DEF
- const FT_Module_Class pshinter_module_class =
- {
+ FT_DEFINE_MODULE(pshinter_module_class,
+
0,
sizeof ( PS_Hinter_ModuleRec ),
"pshinter",
0x10000L,
0x20000L,
- &pshinter_interface, /* module-specific interface */
+ &FTPSHINTER_INTERFACE_GET, /* module-specific interface */
(FT_Module_Constructor)ps_hinter_init,
(FT_Module_Destructor) ps_hinter_done,
(FT_Module_Requester) 0 /* no additional interface for now */
- };
-
+ )
/* END */
diff --git a/src/pshinter/pshmod.h b/src/pshinter/pshmod.h
index 1a91025b2..0ae7e96f5 100644
--- a/src/pshinter/pshmod.h
+++ b/src/pshinter/pshmod.h
@@ -27,7 +27,7 @@
FT_BEGIN_HEADER
- FT_EXPORT_VAR( const FT_Module_Class ) pshinter_module_class;
+ FT_DECLARE_MODULE( pshinter_module_class )
FT_END_HEADER
diff --git a/src/pshinter/pshpic.c b/src/pshinter/pshpic.c
new file mode 100644
index 000000000..51a087988
--- /dev/null
+++ b/src/pshinter/pshpic.c
@@ -0,0 +1,67 @@
+/***************************************************************************/
+/* */
+/* pshpic.c */
+/* */
+/* The FreeType position independent code services for pshinter 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 "pshpic.h"
+
+#ifdef FT_CONFIG_OPTION_PIC
+
+ /* forward declaration of PIC init functions from pshmod.c */
+ void FT_Init_Class_pshinter_interface( FT_Library, PSHinter_Interface*);
+
+ void
+ pshinter_module_class_pic_free( FT_Library library )
+ {
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+ if ( pic_container->pshinter )
+ {
+ FT_FREE( pic_container->pshinter );
+ pic_container->pshinter = NULL;
+ }
+ }
+
+ FT_Error
+ pshinter_module_class_pic_init( FT_Library library )
+ {
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ PSHinterPIC* 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->pshinter = container;
+
+ /* add call to initialization function when you add new scripts */
+ FT_Init_Class_pshinter_interface(library, &container->pshinter_interface);
+
+/*Exit:*/
+ if(error)
+ pshinter_module_class_pic_free(library);
+ return error;
+ }
+
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+/* END */
diff --git a/src/pshinter/pshpic.h b/src/pshinter/pshpic.h
new file mode 100644
index 000000000..3555d8e85
--- /dev/null
+++ b/src/pshinter/pshpic.h
@@ -0,0 +1,53 @@
+/***************************************************************************/
+/* */
+/* pshpic.h */
+/* */
+/* The FreeType position independent code services for pshinter 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 __PSHPIC_H__
+#define __PSHPIC_H__
+
+
+FT_BEGIN_HEADER
+
+#include FT_INTERNAL_PIC_H
+
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FTPSHINTER_INTERFACE_GET pshinter_interface
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#include FT_INTERNAL_POSTSCRIPT_HINTS_H
+
+ typedef struct PSHinterPIC_
+ {
+ PSHinter_Interface pshinter_interface;
+ } PSHinterPIC;
+
+#define GET_PIC(lib) ((PSHinterPIC*)((lib)->pic_container.autofit))
+#define FTPSHINTER_INTERFACE_GET (GET_PIC(library)->pshinter_interface)
+
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __PSHPIC_H__ */
+
+
+/* END */