Compare commits

...

9 Commits

Author SHA1 Message Date
Werner Lemberg
d82ba7dd86 Restore inadvertently deleted ftoption.h. 2009-04-28 10:19:32 +02:00
David Turner
675a903548 introduce service and service list template files, modify cff driver to use them 2009-04-13 03:13:29 +02:00
David Turner
f9ed3bd40c simplify the 'cff_field_handlers' initialization in the PIC table 2009-04-13 01:28:02 +02:00
David Turner
51ad1c7089 convert cff module to FT_PicData 2009-04-13 01:00:39 +02:00
David Turner
5982d4debc formatting and fixing typos 2009-04-13 00:36:45 +02:00
David Turner
329d42d9eb convert autofit module to FT_PicData 2009-04-13 00:33:12 +02:00
David Turner
929ff6996c Introduce FT_PicDataRec in include/freetype/internal/ftpic.h
Modify a few users to use it.
2009-04-13 00:20:03 +02:00
David Turner
5bac49d830 More formatting/cleanup, avoid using FT_Something_Xxxx for internal functions 2009-04-07 00:47:27 +02:00
David Turner
a0bbc06404 Formatting + small cleanup of recent PIC changes.
Replace FT_PIC_Container => FT_PicTableRec, introduce FT_PicTable as pointer to FT_PicTableRec, etc...
2009-04-07 00:30:45 +02:00
53 changed files with 1003 additions and 557 deletions

View File

@ -1,3 +1,34 @@
2009-04-07 David Turner <david@freetype.org>
Formatting + small cleanup of PIC changes
* include/freetype/config/ftoption.h
* include/freetype/internal/ftobjs.h
* include/freetype/internal/ftpic.h
* src/autofit/afpic.c
* src/autofit/afpic.h
* src/base/basepic.c
* src/base/basepic.h
* src/base/ftinit.c
* src/base/ftobjs.c
* src/base/ftpic.c
* src/cff/cffpic.c
* src/cff/cffpic.h
* src/pshinter/pshpic.c
* src/pshinter/pshpic.h
* src/psnames/pspic.c
* src/psnames/pspic.h
* src/raster/rastpic.c
* src/raster/rastpic.h
* src/sfnt/sfntpic.c
* src/sfnt/sfntpic.h
* src/smooth/ftspic.c
* src/smooth/ftspic.h
* src/truetype/ttpic.c
* src/truetype/ttpic.h
2009-04-05 Oran Agra <oran@monfort.co.il>
Add #error to modules and files that do not support PIC yet.

View File

@ -211,7 +211,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_AUTOHINTER_SERVICE(class_, reset_face_, get_global_hints_, \
done_global_hints_, load_glyph_) \
void \
FT_Init_Class_##class_( FT_Library library, \
ft_pic_init_##class_( FT_Library library, \
FT_AutoHinter_ServiceRec* clazz) \
{ \
FT_UNUSED(library); \

View File

@ -352,7 +352,7 @@ FT_BEGIN_HEADER
FT_Error class_##_pic_init( FT_Library library ); \
\
void \
FT_Destroy_Class_##class_( FT_Library library, \
ft_library_pic_free_##class_( FT_Library library, \
FT_Module_Class* clazz ) \
{ \
FT_Memory memory = library->memory; \
@ -363,7 +363,7 @@ FT_BEGIN_HEADER
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
ft_library_pic_alloc_##class_( FT_Library library, \
FT_Module_Class** output_class ) \
{ \
FT_Driver_Class clazz; \

View File

@ -62,6 +62,11 @@ FT_BEGIN_HEADER
#endif
#define FT_GLUE(x,y) FT_GLUE_(x,y)
#define FT_GLUE_(x,y) x##y
#define FT_GLUE3(x,y,z) FT_GLUE(FT_GLUE(x,y),z)
/*************************************************************************/
/* */
/* The min and max functions missing in C. As usual, be careful not to */
@ -223,13 +228,13 @@ FT_BEGIN_HEADER
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DECLARE_CMAP_CLASS(class_) \
void FT_Init_Class_##class_( FT_Library library, FT_CMap_ClassRec* clazz);
void ft_pic_init_##class_( FT_Library library, FT_CMap_ClassRec* clazz);
#define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_, \
char_next_, char_var_index_, char_var_default_, variant_list_, \
charvariant_list_, variantchar_list_) \
void \
FT_Init_Class_##class_( FT_Library library, \
ft_pic_init_##class_( FT_Library library, \
FT_CMap_ClassRec* clazz) \
{ \
FT_UNUSED(library); \
@ -805,7 +810,7 @@ FT_BEGIN_HEADER
/* */
/* debug_hooks :: XXX */
/* */
/* pic_container :: Contains global structs and tables, instead */
/* pic_table :: Contains global structs and tables, instead */
/* of defining them globallly. */
/* */
@ -840,7 +845,7 @@ FT_BEGIN_HEADER
#endif
#ifdef FT_CONFIG_OPTION_PIC
FT_PIC_Container pic_container;
FT_PicTableRec pic_table;
#endif
} FT_LibraryRec;
@ -996,7 +1001,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
raster_reset_, raster_set_mode_, raster_render_, raster_done_) \
void \
FT_Init_Class_##class_( FT_Raster_Funcs* clazz ) \
ft_pic_init_##class_( FT_Raster_Funcs* clazz ) \
{ \
clazz->glyph_format = glyph_format_; \
clazz->raster_new = raster_new_; \
@ -1050,7 +1055,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
transform_, bbox_, prepare_) \
void \
FT_Init_Class_##class_( FT_Glyph_Class* clazz ) \
ft_pic_init_##class_( FT_Glyph_Class* clazz ) \
{ \
clazz->glyph_size = size_; \
clazz->glyph_format = format_; \
@ -1136,7 +1141,7 @@ FT_BEGIN_HEADER
FT_Error class_##_pic_init( FT_Library library ); \
\
void \
FT_Destroy_Class_##class_( FT_Library library, \
ft_library_pic_free_##class_( FT_Library library, \
FT_Module_Class* clazz ) \
{ \
FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \
@ -1147,7 +1152,7 @@ FT_BEGIN_HEADER
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
ft_library_pic_alloc_##class_( FT_Library library, \
FT_Module_Class** output_class ) \
{ \
FT_Renderer_Class* clazz; \
@ -1323,10 +1328,10 @@ FT_BEGIN_HEADER
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DECLARE_MODULE(class_) \
FT_Error FT_Create_Class_##class_( FT_Library library, \
FT_Module_Class** output_class ); \
void FT_Destroy_Class_##class_( FT_Library library, \
FT_Module_Class* clazz );
FT_Error ft_library_pic_alloc_##class_( FT_Library library, \
FT_Module_Class** output_class ); \
void ft_library_pic_free_##class_( FT_Library library, \
FT_Module_Class* clazz );
#define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_, \
interface_, init_, done_, get_interface_) \
@ -1348,8 +1353,8 @@ FT_BEGIN_HEADER
FT_Error class_##_pic_init( FT_Library library ); \
\
void \
FT_Destroy_Class_##class_( FT_Library library, \
FT_Module_Class* clazz ) \
ft_library_pic_free_##class_( FT_Library library, \
FT_Module_Class* clazz ) \
{ \
FT_Memory memory = library->memory; \
class_##_pic_free( library ); \
@ -1358,7 +1363,7 @@ FT_BEGIN_HEADER
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
ft_library_pic_alloc_##class_( FT_Library library, \
FT_Module_Class** output_class ) \
{ \
FT_Memory memory = library->memory; \

View File

@ -26,34 +26,125 @@
#ifndef __FTPIC_H__
#define __FTPIC_H__
FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
typedef struct FT_PIC_Container_
/* A FT_PicDataRec object models a heap-allocated structure
* used to hold data that, in non-PIC builds of the engine,
* would be constant and contain pointers.
*
* The FT_PicDataRec contains book-keeping information about
* the structure, whose exact fields depend on which module
* is defining/using it. The structure itself can be
* accessed as the 'data' field of a FT_PicDataRec object.
*/
typedef struct FT_PicDataRec_* FT_PicData;
/* A FT_PicTableRec object contains the FT_PicDataRec of all
* PIC structures needed by the library at runtime.
*/
typedef struct FT_PicTableRec_* FT_PicTable;
/* A special callback function call to finalize the structure
* backed by a FT_PicDataRec object. It is called by
* ft_pic_table_done_data and its first parameter is the 'data'
* field of the corresponding FT_PicDataRec. Note that the
* PIC structure itself is allocated by ft_pic_table_init_data
* and freed by ft_pic_table_done_data.
*/
typedef void (*FT_PicDataDoneFunc)( void* data, FT_PicTable pic );
/* A special initialization function called by ft_pic_table_init_data
* to initialize a freshly allocated PIC structure.
*/
typedef FT_Error (*FT_PicDataInitFunc)( void* data, FT_PicTable pic );
/* The FT_PicDataRec itself holds a pointer to heap-allocated
* PIC data, a reference count and an optional finalizer function.
*
* One should call ft_pic_table_init_data() to register a new
* heap-allocated PIC structure, which address will be placed
* into the 'data' field.
*/
typedef struct FT_PicDataRec_
{
/* pic containers for base */
void* base;
/* pic containers for modules */
void* autofit;
void* cff;
void* pshinter;
void* psnames;
void* raster;
void* sfnt;
void* smooth;
void* truetype;
} FT_PIC_Container;
void* data;
FT_Int ref_count;
FT_PicDataDoneFunc done;
/* Initialize the various function tables, structs, etc. stored in the container. */
} FT_PicDataRec;
/* When FT_CONFIG_OPTION_PIC is defined, the FT_PicTable
* is used to hold all constant structures that normally
* contain pointers in the normal build of FreeType.
*
* Note that the table itself only contains un-typed pointers
* to base or module-specific data, which will be allocated
* on the heap when the corresponding code is initialized.
*/
typedef struct FT_PicTableRec_
{
FT_Library library;
FT_Memory memory;
/* this macro is used to define the list of FT_PicDataRec
* stored in the PIC table. Add new entries here.
*/
#define FT_PIC_ENTRY_LIST \
_FT_PICDATA( base ) \
_FT_PICDATA( autofit ) \
_FT_PICDATA( cff ) \
/* 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* pshinter;
void* psnames;
void* raster;
void* sfnt;
void* smooth;
void* truetype;
} FT_PicTableRec;
#define FT_LIBRARY_GET_PIC_DATA(library_,name_) \
library_->pic_table.name_->data
/* allocate and initialize a PIC structure in the heap.
* This should be called at module initialization time
* before the PIC data can be used.
*
* if the structure already exists, this simply increments
* its reference count.
*/
FT_BASE( FT_Error )
ft_pic_container_init( FT_Library library );
ft_pic_table_init_data( FT_PicTable table,
FT_PicData data,
FT_UInt data_size,
FT_PicDataInitFunc data_init,
FT_PicDataDoneFunc data_done );
/* Destroy the contents of the container. */
/* finalize and free a given PIC structure. This really
* decrements the reference count and performs destruction
* if it reaches 0.
*
* this should be called a module exit time.
*/
FT_BASE( void )
ft_pic_container_destroy( FT_Library library );
ft_pic_table_done_data( FT_PicTable table,
FT_PicData data );
/* Initialize the PIC table's base */
FT_BASE( FT_Error )
ft_library_pic_init( FT_Library library );
/* Destroy the contents of the PIC table. */
FT_BASE( void )
ft_library_pic_done( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */

View File

@ -250,7 +250,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_SERVICEDESCREC1(class_, serv_id_1, serv_data_1) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
ft_library_pic_free_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
@ -259,7 +259,7 @@ FT_BEGIN_HEADER
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
ft_library_pic_alloc_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
@ -279,7 +279,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_SERVICEDESCREC2(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
ft_library_pic_free_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
@ -288,7 +288,7 @@ FT_BEGIN_HEADER
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
ft_library_pic_alloc_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
@ -310,7 +310,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_SERVICEDESCREC3(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, serv_id_3, serv_data_3) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
ft_library_pic_free_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
@ -319,7 +319,7 @@ FT_BEGIN_HEADER
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
ft_library_pic_alloc_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
@ -344,7 +344,7 @@ FT_BEGIN_HEADER
serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
serv_id_4, serv_data_4) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
ft_library_pic_free_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
@ -353,7 +353,7 @@ FT_BEGIN_HEADER
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
ft_library_pic_alloc_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
@ -380,7 +380,7 @@ FT_BEGIN_HEADER
serv_id_2, serv_data_2, serv_id_3, serv_data_3, serv_id_4, \
serv_data_4, serv_id_5, serv_data_5) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
ft_library_pic_free_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
@ -389,7 +389,7 @@ FT_BEGIN_HEADER
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
ft_library_pic_alloc_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
@ -419,7 +419,7 @@ FT_BEGIN_HEADER
serv_id_4, serv_data_4, serv_id_5, serv_data_5, \
serv_id_6, serv_data_6) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
ft_library_pic_free_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
@ -428,7 +428,7 @@ FT_BEGIN_HEADER
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
ft_library_pic_alloc_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \

View File

@ -47,5 +47,11 @@
#define FT_INTERNAL_AUTOHINT_H <freetype/internal/autohint.h>
#define FT_INTERNAL_SERVICE_DECLARE_H <freetype/internal/services/declare.h>
#define FT_INTERNAL_SERVICE_DEFINE_H <freetype/internal/services/define.h>
#define FT_INTERNAL_SERVICE_LIST_DECLARE_H <freetype/internal/services/listdecl.h>
#define FT_INTERNAL_SERVICE_LIST_DEFINE_H <freetype/internal/services/listdef.h>
/* END */

View File

@ -692,7 +692,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_PSHINTER_INTERFACE(class_, get_globals_funcs_, \
get_t1_funcs_, get_t2_funcs_) \
void \
FT_Init_Class_##class_( FT_Library library, \
ft_pic_init_##class_( FT_Library library, \
PSHinter_Interface* clazz) \
{ \
FT_UNUSED(library); \

View File

@ -0,0 +1,57 @@
/***************************************************************************/
/* */
/* services/declare.h */
/* */
/* The FreeType PostScript info service (specification). */
/* */
/* Copyright 2009 by David Turner */
/* */
/* 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. */
/* */
/***************************************************************************/
/* this header file can be included multipled times and is used
* to declare the types corresponding to a given service described
* by FT_SERVICE_NAME and FT_SERVICE_FIELDS
*
* FT_SERVICE_NAME is the name of the service
* FT_SERVICE_FIELDS is a list of _FT_SERVICE_FIELD(type,varname)
* statements that will be used to define the corresponding service
* structure and pointer types.
*/
#ifndef FT_SERVICE_FIELDS
#error FT_SERVICE_FIELDS must be defined
#endif
#ifndef FT_SERVICE_NAME
#error FT_SERVICE_NAME must be defined
#endif
/* define the service structure and pointer types */
typedef struct FT_GLUE3(FT_Service_,FT_SERVICE_NAME,Rec_)
FT_GLUE3(FT_Service_,FT_SERVICE_NAME,Rec);
typedef struct FT_GLUE3(FT_Service_,FT_SERVICE_NAME,Rec_) const*
FT_GLUE(FT_Service_,FT_SERVICE_NAME);
struct FT_GLUE3(FT_Service_,FT_SERVICE_NAME,Rec_)
{
#define _FT_SERVICE_FIELD(type_,name_) type_ name_;
FT_SERVICE_FIELDS
#undef _FT_SERVICE_FIELD
};
/* declare initialization function for PIC code */
#ifdef FT_CONFIG_OPTION_PIC
void FT_GLUE(ft_pic_service_init_,FT_SERVICE_NAME)
( FT_GLUE3(FT_Service_,FT_SERVICE_NAME,Rec)* clazz );
#endif /* FT_CONFIG_OPTION_PIC */
#undef FT_SERVICE_NAME
#undef FT_SERVICE_FIELDS

View File

@ -0,0 +1,65 @@
/***************************************************************************/
/* */
/* services/define.h */
/* */
/* The FreeType PostScript info service (specification). */
/* */
/* Copyright 2009 by David Turner */
/* */
/* 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. */
/* */
/***************************************************************************/
/* this header file can be included multipled times and is used
* to declare the types corresponding to a given service described
* by FT_SERVICE_NAME and FT_SERVICE_FIELDS
*
* FT_SERVICE_NAME is the name of the service
* FT_SERVICE_FIELDS is a list of _FT_SERVICE_FIELD(type,varname)
* statements that will be used to define the corresponding service
* structure and pointer types.
*/
#ifndef FT_SERVICE_FIELDS
#error FT_SERVICE_FIELDS must be defined
#endif
#ifndef FT_SERVICE_PREFIX
#error FT_SERVICE_PREFIX must be defined
#endif
#ifndef FT_SERVICE_NAME
#error FT_SERVICE_NAME must be defined
#endif
#ifndef FT_CONFIG_OPTION_PIC
static const FT_GLUE3(FT_Service_,FT_SERVICE_NAME,Rec)
FT_GLUE(ft_service_,FT_SERVICE_NAME) =
{
#define _FT_SERVICE_FIELD(type_,name_) \
FT_GLUE(FT_SERVICE_PREFIX,name_),
FT_SERVICE_FIELDS
#undef _FT_SERVICE_FIELD
};
#else /* FT_CONFIG_OPTION_PIC */
void FT_GLUE(ft_pic_service_init_,FT_SERVICE_NAME)(
FT_GLUE3(FT_Service_,FT_SERVICE_NAME,Rec)* clazz )
{
#define _FT_SERVICE_FIELD(type_,name_) \
clazz->name_ = FT_GLUE(FT_SERVICE_PREFIX,name_);
FT_SERVICE_FIELDS
#undef _FT_SERVICE_FIELD
}
#endif /* FT_CONFIG_OPTION_PIC */
#undef FT_SERVICE_NAME
#undef FT_SERVICE_FIELDS
#undef FT_SERVICE_PREFIX

View File

@ -0,0 +1,58 @@
/***************************************************************************/
/* */
/* services/listdecl.h */
/* */
/* Service list declaration template */
/* */
/* Copyright 2009 by David Turner */
/* */
/* 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. */
/* */
/***************************************************************************/
/* this header file can be included multipled times and is used
* to declare a list of services in a given module. It relies on
* FT_SERVICE_LIST_NAME and FT_SERVICE_LIST_FIELDS being defined
*
* FT_SERVICE_NAME is the name of the service list
* FT_SERVICE_ITEMS is a list of _FT_SERVICE_ITEM(id,value)
* statements that will be used to define the corresponding service
* item in the list
*/
#ifndef FT_SERVICE_ITEMS
#error FT_SERVICE_ITEMS must be defined
#endif
#ifndef FT_SERVICE_NAME
#error FT_SERVICE_NAME must be defined
#endif
#ifdef FT_CONFIG_OPTION_PIC
/* For PIC mode, count the number of items in the list
* and define the appropriate array type.
*/
/* compute number of active items in array */
enum {
FT_GLUE(_ft_service_count_,FT_SERVICE_NAME) = 0
#define _FT_SERVICE_ITEM(x,y) +1
FT_SERVICE_ITEMS
#undef _FT_SERVICE_ITEM
};
typedef FT_ServiceDescRec FT_GLUE(FT_ServiceItems_,FT_SERVICE_NAME)
[ FT_GLUE(_ft_service_count_,FT_SERVICE_NAME)+1 ];
void
FT_GLUE(ft_pic_services_init_,FT_SERVICE_NAME)
( FT_ServiceDescRec* items, FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
#undef FT_SERVICE_NAME
#undef FT_SERVICE_ITEMS

View File

@ -0,0 +1,70 @@
/***************************************************************************/
/* */
/* services/listdef.h */
/* */
/* Service list definition template */
/* */
/* Copyright 2009 by David Turner */
/* */
/* 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. */
/* */
/***************************************************************************/
/* this header file can be included multipled times and is used
* to declare a list of services in a given module. It relies on
* FT_SERVICE_LIST_NAME and FT_SERVICE_LIST_FIELDS being defined
*
* FT_SERVICE_NAME is the name of the service list
* FT_SERVICE_ITEMS is a list of _FT_SERVICE_ITEM(id,value)
* statements that will be used to define the corresponding service
* item in the list
*/
#ifndef FT_SERVICE_ITEMS
#error FT_SERVICE_ITEMS must be defined
#endif
#ifndef FT_SERVICE_NAME
#error FT_SERVICE_NAME must be defined
#endif
#ifndef FT_SERVICE_VARNAME
#error FT_SERVICE_VARNAME must be defined
#endif
#ifndef FT_CONFIG_OPTION_PIC
static const FT_ServiceDescRec FT_SERVICE_VARNAME[] =
{
#define _FT_SERVICE_ITEM(id_,value_) { id_, value_ },
FT_SERVICE_ITEMS
#undef _FT_SERVICE_ITEM
{ NULL, NULL }
};
#else /* FT_CONFIG_OPTION_PIC */
void
FT_GLUE(ft_pic_services_init_,FT_SERVICE_NAME)
( FT_ServiceDescRec* items, FT_Library library )
{
FT_ServiceDescRec* desc = items;
#define _FT_SERVICE_ITEM(id_,value_) \
desc->serv_id = FT_GLUE(FT_SERVICE_ID_,id_); \
desc->serv_data = value_; \
desc ++;
FT_SERVICE_ITEMS
#undef _FT_SERVICE_ITEM
desc->serv_id = NULL;
desc->serv_data = NULL;
}
#endif /* FT_CONFIG_OPTION_PIC */
#undef FT_SERVICE_NAME
#undef FT_SERVICE_VARNAME
#undef FT_SERVICE_ITEMS

View File

@ -57,7 +57,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_SERVICE_BDFRec(class_, get_charset_id_, get_property_) \
void \
FT_Init_Class_##class_( FT_Service_BDFRec* clazz ) \
ft_pic_init_##class_( FT_Service_BDFRec* clazz ) \
{ \
clazz->get_charset_id = get_charset_id_; \
clazz->get_property = get_property_; \

View File

@ -60,7 +60,7 @@ FT_BEGIN_HEADER
#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_pic_init_##class_( FT_Library library, \
FT_Service_CIDRec* clazz) \
{ \
FT_UNUSED(library); \

View File

@ -63,7 +63,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_SERVICE_GLYPHDICTREC(class_, get_name_, name_index_) \
void \
FT_Init_Class_##class_( FT_Library library, \
ft_pic_init_##class_( FT_Library library, \
FT_Service_GlyphDictRec* clazz) \
{ \
FT_UNUSED(library); \

View File

@ -82,7 +82,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_SERVICE_MULTIMASTERSREC(class_, get_mm_, set_mm_design_, \
set_mm_blend_, get_mm_var_, set_var_design_) \
void \
FT_Init_Class_##class_( FT_Service_MultiMastersRec* clazz ) \
ft_pic_init_##class_( FT_Service_MultiMastersRec* clazz ) \
{ \
clazz->get_mm = get_mm_; \
clazz->set_mm_design = set_mm_design_; \

View File

@ -58,7 +58,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_SERVICE_PSFONTNAMEREC(class_, get_ps_font_name_) \
void \
FT_Init_Class_##class_( FT_Library library, \
ft_pic_init_##class_( FT_Library library, \
FT_Service_PsFontNameRec* clazz) \
{ \
FT_UNUSED(library); \

View File

@ -136,7 +136,7 @@ FT_BEGIN_HEADER
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_pic_init_##class_( FT_Library library, \
FT_Service_PsCMapsRec* clazz) \
{ \
FT_UNUSED(library); \

View File

@ -25,7 +25,6 @@
FT_BEGIN_HEADER
#define FT_SERVICE_ID_POSTSCRIPT_INFO "postscript-info"
@ -44,41 +43,16 @@ FT_BEGIN_HEADER
(*PS_GetFontPrivateFunc)( FT_Face face,
PS_PrivateRec* afont_private );
#define FT_PSINFO_SERVICE_FIELDS \
_FT_SERVICE_FIELD( PS_GetFontInfoFunc, get_font_info ) \
_FT_SERVICE_FIELD( PS_GetFontExtraFunc, get_font_extra ) \
_FT_SERVICE_FIELD( PS_HasGlyphNamesFunc, has_glyph_names ) \
_FT_SERVICE_FIELD( PS_GetFontPrivateFunc, get_font_private ) \
FT_DEFINE_SERVICE( PsInfo )
{
PS_GetFontInfoFunc ps_get_font_info;
PS_GetFontExtraFunc ps_get_font_extra;
PS_HasGlyphNamesFunc ps_has_glyph_names;
PS_GetFontPrivateFunc ps_get_font_private;
};
#define FT_SERVICE_NAME PsInfo
#define FT_SERVICE_FIELDS FT_PSINFO_SERVICE_FIELDS
#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 */
#include FT_INTERNAL_SERVICE_DECLARE_H
/* */

View File

@ -80,7 +80,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_SERVICE_SFNT_TABLEREC(class_, load_, get_, info_) \
void \
FT_Init_Class_##class_( FT_Service_SFNT_TableRec* clazz ) \
ft_pic_init_##class_( FT_Service_SFNT_TableRec* clazz ) \
{ \
clazz->load_table = load_; \
clazz->get_table = get_; \

View File

@ -86,7 +86,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_SERVICE_TTCMAPSREC(class_, get_cmap_info_) \
void \
FT_Init_Class_##class_( FT_Library library, \
ft_pic_init_##class_( FT_Library library, \
FT_Service_TTCMapsRec* clazz) \
{ \
FT_UNUSED(library); \

View File

@ -49,7 +49,7 @@ FT_BEGIN_HEADER
#define FT_DEFINE_SERVICE_TTGLYFREC(class_, get_location_ ) \
void \
FT_Init_Class_##class_( FT_Service_TTGlyfRec* clazz ) \
ft_pic_init_##class_( FT_Service_TTGlyfRec* clazz ) \
{ \
clazz->get_location = get_location_; \
}

View File

@ -842,7 +842,7 @@ FT_BEGIN_HEADER
get_kerning_, load_font_dir_, load_hmtx_, load_eblc_, free_eblc_, \
set_sbit_strike_, load_strike_metrics_, get_metrics_ ) \
void \
FT_Init_Class_##class_( FT_Library library, SFNT_Interface* clazz ) \
ft_pic_init_##class_( FT_Library library, SFNT_Interface* clazz ) \
{ \
FT_UNUSED(library); \
FT_INTERNAL(goto_table,goto_table_) \

View File

@ -83,7 +83,7 @@
0x10000L, /* version 1.0 of the autofitter */
0x20000L, /* requires FreeType 2.0 or above */
(const void*)&AF_AF_AUTOFITTER_SERVICE_GET,
(const void*)&AF_AUTOFITTER_SERVICE_GET,
(FT_Module_Constructor)af_autofitter_init,
(FT_Module_Destructor) af_autofitter_done,

View File

@ -24,7 +24,7 @@
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from afmodule.c */
void FT_Init_Class_af_autofitter_service( FT_Library, FT_AutoHinter_ServiceRec*);
void ft_pic_init_af_autofitter_service( FT_Library, FT_AutoHinter_ServiceRec*);
/* forward declaration of PIC init functions from script classes */
#include "aflatin.h"
@ -33,32 +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_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->autofit )
{
FT_FREE( pic_container->autofit );
pic_container->autofit = NULL;
}
}
FT_Error
autofit_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_UInt ss;
FT_Error error = FT_Err_Ok;
AFModulePIC* 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->autofit = container;
AFModulePIC* container = _autofit;
FT_UInt ss;
/* initialize pointer table - this is how the module usually expects this data */
for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
@ -66,26 +45,34 @@
container->af_script_classes[ss] = &container->af_script_classes_rec[ss];
}
container->af_script_classes[AF_SCRIPT_CLASSES_COUNT-1] = NULL;
/* add call to initialization function when you add new scripts */
ss = 0;
FT_Init_Class_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_Init_Class_af_latin2_script_class(&container->af_script_classes_rec[ss++]);
ft_pic_init_af_latin2_script_class(&container->af_script_classes_rec[ss++]);
#endif
FT_Init_Class_af_latin_script_class(&container->af_script_classes_rec[ss++]);
FT_Init_Class_af_cjk_script_class(&container->af_script_classes_rec[ss++]);
FT_Init_Class_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_Init_Class_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,38 +19,37 @@
#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_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_container.autofit))
#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)
#define AF_GET_PIC(lib) ((AFModulePIC*)FT_LIBRARY_GET_PIC_DATA(lib,autofit))
#define AF_SCRIPT_CLASSES_GET (AF_GET_PIC(FT_FACE_LIBRARY(globals->face))->af_script_classes)
#define AF_AUTOFITTER_SERVICE_GET (AF_GET_PIC(library)->af_autofitter_service)
#endif /* FT_CONFIG_OPTION_PIC */

View File

@ -368,12 +368,12 @@ extern void* _af_debug_hints;
#define AF_DECLARE_SCRIPT_CLASS(script_class) \
FT_LOCAL(void) \
FT_Init_Class_##script_class(AF_ScriptClassRec* ac);
ft_pic_init_##script_class(AF_ScriptClassRec* ac);
#define AF_DEFINE_SCRIPT_CLASS(script_class, script_, ranges, m_size, \
m_init, m_scale, m_done, h_init, h_apply) \
FT_LOCAL_DEF(void) \
FT_Init_Class_##script_class(AF_ScriptClassRec* ac) \
ft_pic_init_##script_class(AF_ScriptClassRec* ac) \
{ \
ac->script = script_; \
ac->script_uni_ranges = ranges; \

View File

@ -24,59 +24,54 @@
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftglyph.c */
void FT_Init_Class_ft_outline_glyph_class(FT_Glyph_Class*);
void FT_Init_Class_ft_bitmap_glyph_class(FT_Glyph_Class*);
void ft_pic_init_ft_outline_glyph_class(FT_Glyph_Class*);
void ft_pic_init_ft_bitmap_glyph_class(FT_Glyph_Class*);
/* forward declaration of PIC init functions from ftinit.c */
FT_Error ft_create_default_module_classes(FT_Library);
void ft_destroy_default_module_classes(FT_Library);
void
ft_base_pic_free( FT_Library library )
static void
pic_base_done( void* base, FT_PicTable pic )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->base )
{
/* Destroy default module classes (in case FT_Add_Default_Modules was used) */
ft_destroy_default_module_classes( library );
FT_UNUSED(base);
FT_FREE( pic_container->base );
pic_container->base = NULL;
}
/* Destroy default module classes (in case FT_Add_Default_Modules was used) */
ft_destroy_default_module_classes( pic->library );
}
static FT_Error
pic_base_init( void* data, FT_PicTable pic )
{
BasePIC* base = (BasePIC*)data;
FT_Error error;
/* initialize default modules list and pointers */
error = ft_create_default_module_classes( pic->library );
if ( error )
goto Exit;
/* initialize pointer table - this is how the module usually expects this data */
ft_pic_init_ft_outline_glyph_class(&base->ft_outline_glyph_class);
ft_pic_init_ft_bitmap_glyph_class(&base->ft_bitmap_glyph_class);
Exit:
return error;
}
FT_Error
ft_base_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
BasePIC* container;
FT_Memory memory = library->memory;
FT_PicTable pic_table = &library->pic_table;
/* 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->base = container;
/* initialize default modules list and pointers */
error = ft_create_default_module_classes( library );
if ( error )
goto Exit;
/* initialize pointer table - this is how the module usually expects this data */
FT_Init_Class_ft_outline_glyph_class(&container->ft_outline_glyph_class);
FT_Init_Class_ft_bitmap_glyph_class(&container->ft_bitmap_glyph_class);
Exit:
if(error)
ft_base_pic_free(library);
return error;
return ft_pic_table_init_data( pic_table,
pic_table->base,
sizeof(BasePIC),
pic_base_init,
pic_base_done );
}
#endif /* FT_CONFIG_OPTION_PIC */

View File

@ -40,10 +40,10 @@ FT_BEGIN_HEADER
FT_Glyph_Class ft_bitmap_glyph_class;
} BasePIC;
#define GET_PIC(lib) ((BasePIC*)((lib)->pic_container.base))
#define GET_PIC(lib) ((BasePIC*)((lib)->pic_table.base))
#define FT_OUTLINE_GLYPH_CLASS_GET (&GET_PIC(library)->ft_outline_glyph_class)
#define FT_BITMAP_GLYPH_CLASS_GET (&GET_PIC(library)->ft_bitmap_glyph_class)
#define FT_DEFAULT_MODULES_GET (GET_PIC(library)->default_module_classes)
#define FT_DEFAULT_MODULES_GET (const FT_Module_Class* const*)(GET_PIC(library)->default_module_classes)
void
ft_base_pic_free( FT_Library library );

View File

@ -38,12 +38,12 @@
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
if ( service && service->ps_get_font_extra )
if ( service && service->get_font_extra )
{
PS_FontExtraRec extra;
if ( !service->ps_get_font_extra( face, &extra ) &&
if ( !service->get_font_extra( face, &extra ) &&
extra.fs_type != 0 )
return extra.fs_type;
}

View File

@ -88,8 +88,8 @@
/* declare the module's class creation/destruction functions */
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) \
FT_EXTERNC FT_Error FT_Create_Class_##x( FT_Library library, FT_Module_Class** output_class ); \
FT_EXTERNC void FT_Destroy_Class_##x( FT_Library library, FT_Module_Class* clazz );
FT_EXTERNC FT_Error ft_library_pic_alloc_##x( FT_Library library, FT_Module_Class** output_class ); \
FT_EXTERNC void ft_library_pic_free_##x( FT_Library library, FT_Module_Class* clazz );
#include FT_CONFIG_MODULES_H
@ -106,7 +106,7 @@
/* destroy all module classes */
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) \
if ( classes[i] ) { FT_Destroy_Class_##x(library, classes[i]); } \
if ( classes[i] ) { ft_library_pic_free_##x(library, classes[i]); } \
i++; \
FT_BASE_DEF( void )
@ -115,28 +115,21 @@
FT_Module_Class** classes;
FT_Memory memory;
FT_UInt i;
BasePIC* pic_container = library->pic_container.base;
BasePIC* pic_table = FT_LIBRARY_GET_PIC_DATA(library, base);
if ( !pic_container->default_module_classes )
if ( !pic_table->default_module_classes )
return;
memory = library->memory;
classes = pic_container->default_module_classes;
classes = pic_table->default_module_classes;
i = 0;
#include FT_CONFIG_MODULES_H
FT_FREE( classes );
pic_container->default_module_classes = 0;
pic_table->default_module_classes = 0;
}
/* initialize all module classes and the pointer table */
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) \
error = FT_Create_Class_##x(library, &clazz); \
if (error) goto Exit; \
classes[i++] = clazz;
FT_BASE_DEF( FT_Error )
ft_create_default_module_classes( FT_Library library )
{
@ -145,27 +138,35 @@
FT_Module_Class** classes;
FT_Module_Class* clazz;
FT_UInt i;
BasePIC* pic_container = library->pic_container.base;
BasePIC* pic_table = FT_LIBRARY_GET_PIC_DATA(library, base);
memory = library->memory;
pic_container->default_module_classes = 0;
pic_table->default_module_classes = 0;
if ( FT_ALLOC(classes, sizeof(FT_Module_Class*) * (FT_NUM_MODULE_CLASSES + 1) ) )
if ( FT_NEW_ARRAY(classes, FT_NUM_MODULE_CLASSES + 1 ) )
return error;
/* initialize all pointers to 0, especially the last one */
for (i = 0; i < FT_NUM_MODULE_CLASSES; i++)
classes[i] = 0;
classes[FT_NUM_MODULE_CLASSES] = 0;
i = 0;
/* initialize all module classes and the pointer table */
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) \
error = ft_library_pic_alloc_##x(library, &clazz); \
if (error) \
goto Exit; \
\
classes[i++] = clazz;
#include FT_CONFIG_MODULES_H
#undef FT_USE_MODULE
Exit:
if (error) ft_destroy_default_module_classes( library );
else pic_container->default_module_classes = classes;
Exit:
if (error)
ft_destroy_default_module_classes( library );
else
pic_table->default_module_classes = classes;
return error;
return error;
}

View File

@ -4125,7 +4125,7 @@
#ifdef FT_CONFIG_OPTION_PIC
/* initialize position independent code containers */
error = ft_pic_container_init( library );
error = ft_library_pic_init( library );
if ( error )
goto Fail;
#endif
@ -4144,7 +4144,7 @@
Fail:
#ifdef FT_CONFIG_OPTION_PIC
ft_pic_container_destroy( library );
ft_library_pic_done( library );
#endif
FT_FREE( library );
return error;
@ -4264,7 +4264,7 @@
#ifdef FT_CONFIG_OPTION_PIC
/* Destroy pic container contents */
ft_pic_container_destroy( library );
ft_library_pic_done( library );
#endif
FT_FREE( library );

View File

@ -26,12 +26,74 @@
/* documentation is in ftpic.h */
FT_BASE_DEF( FT_Error )
ft_pic_container_init( FT_Library library )
ft_pic_table_init_data( FT_PicTable pic,
FT_PicData data,
FT_UInt data_size,
FT_PicDataInitFunc data_init,
FT_PicDataDoneFunc data_done )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
void* pic_data = data->data;
FT_Error error = 0;
FT_Memory memory = pic->memory;
FT_MEM_SET( pic_container, 0, sizeof(*pic_container) );
/* if the PIC structure already exist, just increment its
* reference count
*/
if (pic_data != NULL)
{
data->ref_count += 1;
return 0;
}
if ( FT_ALLOC( pic_data, data_size ) )
goto Exit;
error = data_init( pic_data, pic );
if (error)
{
if (data_done)
data_done( pic_data, pic );
FT_FREE( pic_data );
goto Exit;
}
data->data = pic_data;
data->ref_count = 1;
data->done = data_done;
Exit:
return error;
}
FT_BASE_DEF( void )
ft_pic_table_done_data( FT_PicTable pic,
FT_PicData data )
{
FT_Memory memory = pic->memory;
if ( --data->ref_count != 0 )
return;
if (data->done)
data->done( data->data, pic );
FT_FREE(data->data);
data->done = NULL;
}
FT_BASE_DEF( FT_Error )
ft_library_pic_init( FT_Library library )
{
FT_PicTable pic = &library->pic_table;
FT_Error error = FT_Err_Ok;
FT_ZERO(pic);
pic->library = library;
pic->memory = library->memory;
error = ft_base_pic_init( library );
if(error)
@ -43,7 +105,7 @@
/* Destroy the contents of the container. */
FT_BASE_DEF( void )
ft_pic_container_destroy( FT_Library library )
ft_library_pic_done( FT_Library library )
{
ft_base_pic_free( library );
}

View File

@ -38,8 +38,8 @@
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
if ( service && service->ps_get_font_info )
error = service->ps_get_font_info( face, afont_info );
if ( service && service->get_font_info )
error = service->get_font_info( face, afont_info );
}
return error;
@ -59,8 +59,8 @@
{
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
if ( service && service->ps_has_glyph_names )
result = service->ps_has_glyph_names( face );
if ( service && service->has_glyph_names )
result = service->has_glyph_names( face );
}
return result;
@ -83,8 +83,8 @@
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
if ( service && service->ps_get_font_private )
error = service->ps_get_font_private( face, afont_private );
if ( service && service->get_font_private )
error = service->get_font_private( face, afont_private );
}
return error;

View File

@ -329,9 +329,10 @@
static FT_Error
cff_ps_get_font_info( CFF_Face face,
cff_ps_get_font_info( FT_Face face_,
PS_FontInfoRec* afont_info )
{
CFF_Face face = (CFF_Face)face_;
CFF_Font cff = (CFF_Font)face->extra.data;
FT_Error error = FT_Err_Ok;
@ -378,13 +379,22 @@
}
#define FT_SERVICE_FIELDS FT_PSINFO_SERVICE_FIELDS
#define FT_SERVICE_NAME PsInfo
#define FT_SERVICE_PREFIX cff_ps_
#define cff_ps_get_font_extra NULL
#define cff_ps_get_font_private NULL
#include FT_INTERNAL_SERVICE_DEFINE_H
#if 0
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 */
)
#endif
/*
* POSTSCRIPT NAME SERVICE
@ -585,20 +595,20 @@
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
#define FT_SERVICE_ITEMS CFF_SERVICE_ITEMS
#define FT_SERVICE_NAME cff
#define FT_SERVICE_VARNAME cff_services
#include FT_INTERNAL_SERVICE_LIST_DEFINE_H
#if 0
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,
IF_GLYPH_NAMES(
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
)

View File

@ -559,20 +559,6 @@
return error;
}
#define CFF_FIELD_NUM( code, name ) \
CFF_FIELD( code, name, cff_kind_num )
#define CFF_FIELD_FIXED( code, name ) \
CFF_FIELD( code, name, cff_kind_fixed )
#define CFF_FIELD_FIXED_1000( code, name ) \
CFF_FIELD( code, name, cff_kind_fixed_thousand )
#define CFF_FIELD_STRING( code, name ) \
CFF_FIELD( code, name, cff_kind_string )
#define CFF_FIELD_BOOL( code, name ) \
CFF_FIELD( code, name, cff_kind_bool )
#define CFF_FIELD_DELTA( code, name, max ) \
CFF_FIELD( code, name, cff_kind_delta )
#define CFFCODE_TOPDICT 0x1000
#define CFFCODE_PRIVATE 0x2000
@ -587,7 +573,6 @@
0, 0 \
},
#undef CFF_FIELD
#define CFF_FIELD( code, name, kind ) \
{ \
kind, \
@ -597,7 +582,6 @@
0, 0, 0 \
},
#undef CFF_FIELD_DELTA
#define CFF_FIELD_DELTA( code, name, max ) \
{ \
cff_kind_delta, \
@ -620,82 +604,48 @@
#else /* FT_CONFIG_OPTION_PIC */
void FT_Destroy_Class_cff_field_handlers(FT_Library library, CFF_Field_Handler* clazz)
void
cff_field_handlers_init( CFF_Field_Handler* clazz )
{
FT_Memory memory = library->memory;
if ( clazz )
FT_FREE( clazz );
}
#define CFF_FIELD_CALLBACK( code_, name_ ) \
clazz->kind = cff_kind_callback; \
clazz->code = code_ | CFFCODE; \
clazz->offset = 0; \
clazz->size = 0; \
clazz->reader = cff_parse_ ## name_; \
clazz->array_max = 0; \
clazz->count_offset = 0; \
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;
#define CFF_FIELD( code_, name_, kind_ ) \
clazz->kind = kind_; \
clazz->code = code_ | CFFCODE; \
clazz->offset = FT_FIELD_OFFSET( name_ ); \
clazz->size = FT_FIELD_SIZE( name_ ); \
clazz->reader = 0; \
clazz->array_max = 0; \
clazz->count_offset = 0; \
clazz++;
#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++;
#define CFF_FIELD_DELTA( code_, name_, max_ ) \
clazz->kind = cff_kind_delta; \
clazz->code = code_ | CFFCODE; \
clazz->offset = FT_FIELD_OFFSET( name_ ); \
clazz->size = FT_FIELD_SIZE_DELTA( name_ ); \
clazz->reader = 0; \
clazz->array_max = max_; \
clazz->count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
clazz++;
#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;
clazz->kind = 0;
clazz->code = 0;
clazz->offset = 0;
clazz->size = 0;
clazz->reader = 0;
clazz->array_max = 0;
clazz->count_offset = 0;
}

View File

@ -24,73 +24,56 @@
#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*);
void ft_pic_init_cff_service_ps_info( FT_Library, FT_Service_PsInfoRec*);
void ft_pic_init_cff_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
void ft_pic_init_cff_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
void ft_pic_init_cff_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
void ft_pic_init_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*);
void cff_pic_field_handlers_init( CFF_Field_Handler* );
#if 0 /* defined by cffcmap.h */
/* 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 ft_pic_init_cff_cmap_encoding_class_rec( FT_Library, FT_CMap_ClassRec*);
void ft_pic_init_cff_cmap_unicode_class_rec( FT_Library, FT_CMap_ClassRec*);
#endif
void
cff_driver_class_pic_free( FT_Library library )
static FT_Error
pic_cff_init( void* _cff, FT_PicTable pic )
{
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_Library library = pic->library;
FT_Error error = FT_Err_Ok;
CffModulePIC* container = (CffModulePIC*) _cff;
ft_pic_init_cff_service_ps_info (library, &container->cff_service_ps_info);
ft_pic_init_cff_service_glyph_dict (library, &container->cff_service_glyph_dict);
ft_pic_init_cff_service_ps_name (library, &container->cff_service_ps_name);
ft_pic_init_cff_service_get_cmap_info(library, &container->cff_service_get_cmap_info);
ft_pic_init_cff_service_cid_info (library, &container->cff_service_cid_info);
ft_pic_init_cff_cmap_encoding_class_rec (library,
&container->cff_cmap_encoding_class_rec);
ft_pic_init_cff_cmap_unicode_class_rec (library,
&container->cff_cmap_unicode_class_rec);
cff_pic_field_handlers_init(container->cff_field_handlers);
ft_pic_services_init_Cff( &container->cff_services, library );
return 0;
}
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;
FT_PicTable pic = &library->pic_table;
/* 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;
return ft_pic_table_init_data( pic, pic->cff,
sizeof(CffModulePIC),
pic_cff_init,
NULL );
}
#endif /* FT_CONFIG_OPTION_PIC */

View File

@ -19,21 +19,38 @@
#ifndef __CFFPIC_H__
#define __CFFPIC_H__
FT_BEGIN_HEADER
#include FT_INTERNAL_OBJECTS_H
/* CFF services list */
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
# define IF_GLYPH_NAMES(x) x
#else
# define IF_GLYPH_NAMES(x) /* nothing */
#endif
#define CFF_SERVICE_ITEMS \
_FT_SERVICE_ITEM( XF86_NAME, FT_XF86_FORMAT_CFF ) \
_FT_SERVICE_ITEM( POSTSCRIPT_INFO, &FT_CFF_SERVICE_PS_INFO_GET ) \
_FT_SERVICE_ITEM( POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET ) \
IF_GLYPH_NAMES( \
_FT_SERVICE_ITEM( GLYPH_DICT, &FT_CFF_SERVICE_GLYPH_DICT_GET ) \
) \
_FT_SERVICE_ITEM( TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET ) \
_FT_SERVICE_ITEM( CID, &FT_CFF_SERVICE_CID_INFO_GET ) \
#define FT_SERVICE_NAME Cff
#define FT_SERVICE_ITEMS CFF_SERVICE_ITEMS
#include FT_INTERNAL_SERVICE_LIST_DECLARE_H
#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
#define FT_CFF_CONST_(name_) cff_##name_
#else /* FT_CONFIG_OPTION_PIC */
@ -44,32 +61,44 @@ FT_BEGIN_HEADER
#include FT_SERVICE_TT_CMAP_H
#include FT_SERVICE_CID_H
/* count the number of items declared by cfftoken.h */
enum {
CFF_FIELD_HANDLER_COUNT = 0
#define CFF_FIELD(x,y,z) +1
#define CFF_FIELD_CALLBACK(x,y) +1
#define CFF_FIELD_DELTA(x,y,z) +1
#include "cfftoken.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_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;
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;
CFF_Field_Handler cff_field_handlers[CFF_FIELD_HANDLER_COUNT+1];
FT_ServiceItems_Cff cff_services;
} 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)
#define CFF_GET_PIC(lib) ((CffModulePIC*)FT_LIBRARY_GET_PIC_DATA(lib,cff))
#define FT_CFF_CONST_(name_) (CFF_GET_PIC(library)->cff_##name_)
#endif /* FT_CONFIG_OPTION_PIC */
#define FT_CFF_SERVICE_PS_INFO_GET FT_CFF_CONST_(service_ps_info)
#define FT_CFF_SERVICE_GLYPH_DICT_GET FT_CFF_CONST_(service_glyph_dict)
#define FT_CFF_SERVICE_PS_NAME_GET FT_CFF_CONST_(service_ps_name)
#define FT_CFF_SERVICE_GET_CMAP_INFO_GET FT_CFF_CONST_(service_get_cmap_info)
#define FT_CFF_SERVICE_CID_INFO_GET FT_CFF_CONST_(service_cid_info)
#define FT_CFF_SERVICES_GET FT_CFF_CONST_(services)
#define FT_CFF_CMAP_ENCODING_CLASS_REC_GET FT_CFF_CONST_(cmap_encoding_class_rec)
#define FT_CFF_CMAP_UNICODE_CLASS_REC_GET FT_CFF_CONST_(cmap_unicode_class_rec)
#define FT_CFF_FIELD_HANDLERS_GET FT_CFF_CONST_(field_handlers)
/* */
FT_END_HEADER

View File

@ -15,6 +15,42 @@
/* */
/***************************************************************************/
#ifndef CFF_FIELD
#error CFF_FIELD must be defined
#endif
#ifndef CFF_FIELD_DELTA
#error CFF_FIELD_DELTA must be defined
#endif
#ifndef CFF_FIELD_CALLBACK
#error CFF_FIELD_CALLBACK must be defined
#endif
#ifndef CFF_FIELD_NUM
#define CFF_FIELD_NUM( code, name ) \
CFF_FIELD( code, name, cff_kind_num )
#endif
#ifndef CFF_FIELD_FIXED
#define CFF_FIELD_FIXED( code, name ) \
CFF_FIELD( code, name, cff_kind_fixed )
#endif
#ifndef CFF_FIELD_FIXED_1000
#define CFF_FIELD_FIXED_1000( code, name ) \
CFF_FIELD( code, name, cff_kind_fixed_thousand )
#endif
#ifndef CFF_FIELD_STRING
#define CFF_FIELD_STRING( code, name ) \
CFF_FIELD( code, name, cff_kind_string )
#endif
#ifndef CFF_FIELD_BOOL
#define CFF_FIELD_BOOL( code, name ) \
CFF_FIELD( code, name, cff_kind_bool )
#endif
#undef FT_STRUCTURE
#define FT_STRUCTURE CFF_FontRecDictRec
@ -93,5 +129,14 @@
CFF_FIELD_NUM ( 20, default_width )
CFF_FIELD_NUM ( 21, nominal_width )
#undef CFF_FIELD_STRING
#undef CFF_FIELD_BOOL
#undef CFF_FIELD_NUM
#undef CFF_FIELD_FIXED
#undef CFF_FIELD_FIXED_1000
#undef CFF_FIELD_DELTA
#undef CFF_FIELD_CALLBACK
#undef CFF_FIELD
/* END */

View File

@ -24,44 +24,46 @@
#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 ft_pic_init_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_PicTable pic_table = &library->pic_table;
FT_Memory memory = library->memory;
if ( pic_table->pshinter )
{
FT_FREE( pic_container->pshinter );
pic_container->pshinter = NULL;
FT_FREE( pic_table->pshinter );
pic_table->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;
FT_PicTable pic_table = &library->pic_table;
FT_Error error = FT_Err_Ok;
FT_Memory memory = library->memory;
PSHinterPIC* container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
if ( FT_NEW ( container ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
pic_container->pshinter = container;
pic_table->pshinter = container;
/* add call to initialization function when you add new scripts */
FT_Init_Class_pshinter_interface(library, &container->pshinter_interface);
ft_pic_init_pshinter_interface(library, &container->pshinter_interface);
/*Exit:*/
if(error)
pshinter_module_class_pic_free(library);
return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */

View File

@ -37,7 +37,7 @@ FT_BEGIN_HEADER
PSHinter_Interface pshinter_interface;
} PSHinterPIC;
#define GET_PIC(lib) ((PSHinterPIC*)((lib)->pic_container.autofit))
#define GET_PIC(lib) ((PSHinterPIC*)((lib)->pic_table.autofit))
#define FTPSHINTER_INTERFACE_GET (GET_PIC(library)->pshinter_interface)

View File

@ -24,49 +24,58 @@
#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*);
FT_Error ft_library_pic_alloc_pscmaps_services ( FT_Library, FT_ServiceDescRec** );
void ft_library_pic_free_pscmaps_services( FT_Library, FT_ServiceDescRec* );
void ft_pic_init_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 )
FT_PicTable pic_table = &library->pic_table;
FT_Memory memory = library->memory;
if ( pic_table->psnames )
{
PSModulePIC* container = (PSModulePIC*)pic_container->psnames;
PSModulePIC* container = (PSModulePIC*)pic_table->psnames;
if(container->pscmaps_services)
FT_Destroy_Class_pscmaps_services(library, container->pscmaps_services);
ft_library_pic_free_pscmaps_services(library, container->pscmaps_services);
container->pscmaps_services = NULL;
FT_FREE( container );
pic_container->psnames = NULL;
pic_table->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;
FT_PicTable pic_table = &library->pic_table;
FT_Error error = FT_Err_Ok;
FT_Memory memory = library->memory;
PSModulePIC* container;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
if ( FT_NEW ( container ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
pic_container->psnames = container;
pic_table->psnames = container;
/* initialize pointer table - this is how the module usually expects this data */
error = FT_Create_Class_pscmaps_services(library, &container->pscmaps_services);
error = ft_library_pic_alloc_pscmaps_services(library, &container->pscmaps_services);
if(error)
goto Exit;
FT_Init_Class_pscmaps_interface(library, &container->pscmaps_interface);
ft_pic_init_pscmaps_interface(library, &container->pscmaps_interface);
Exit:
if(error)
psnames_module_class_pic_free(library);
return error;
}

View File

@ -38,7 +38,7 @@ FT_BEGIN_HEADER
FT_Service_PsCMapsRec pscmaps_interface;
} PSModulePIC;
#define GET_PIC(lib) ((PSModulePIC*)((lib)->pic_container.psnames))
#define GET_PIC(lib) ((PSModulePIC*)((lib)->pic_table.psnames))
#define FT_PSCMAPS_SERVICES_GET (GET_PIC(library)->pscmaps_services)
#define FT_PSCMAPS_INTERFACE_GET (GET_PIC(library)->pscmaps_interface)

View File

@ -24,20 +24,23 @@
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftraster.c */
void FT_Init_Class_ft_standard_raster(FT_Raster_Funcs*);
void ft_pic_init_ft_standard_raster(FT_Raster_Funcs*);
void
ft_raster1_renderer_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->raster )
FT_PicTable pic_table = &library->pic_table;
FT_Memory memory = library->memory;
if ( pic_table->raster )
{
RasterPIC* container = (RasterPIC*)pic_container->raster;
RasterPIC* container = (RasterPIC*)pic_table->raster;
if(--container->ref_count)
return;
FT_FREE( container );
pic_container->raster = NULL;
pic_table->raster = NULL;
}
}
@ -45,31 +48,32 @@
FT_Error
ft_raster1_renderer_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
RasterPIC* container;
FT_Memory memory = library->memory;
FT_PicTable pic_table = &library->pic_table;
FT_Error error = FT_Err_Ok;
FT_Memory memory = library->memory;
RasterPIC* container;
/* since this function also serve raster5 renderer,
it implements reference counting */
if(pic_container->raster)
if(pic_table->raster)
{
((RasterPIC*)pic_container->raster)->ref_count++;
((RasterPIC*)pic_table->raster)->ref_count++;
return error;
}
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
if ( FT_NEW ( container ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
pic_container->raster = container;
pic_table->raster = container;
container->ref_count = 1;
/* initialize pointer table - this is how the module usually expects this data */
FT_Init_Class_ft_standard_raster(&container->ft_standard_raster);
ft_pic_init_ft_standard_raster(&container->ft_standard_raster);
/*Exit:*/
if(error)
ft_raster1_renderer_class_pic_free(library);
return error;
}
@ -78,6 +82,7 @@
{
return ft_raster1_renderer_class_pic_init(library);
}
void ft_raster5_renderer_class_pic_free(FT_Library library)
{
ft_raster1_renderer_class_pic_free(library);

View File

@ -35,7 +35,7 @@ FT_BEGIN_HEADER
FT_Raster_Funcs ft_standard_raster;
} RasterPIC;
#define GET_PIC(lib) ((RasterPIC*)((lib)->pic_container.raster))
#define GET_PIC(lib) ((RasterPIC*)((lib)->pic_table.raster))
#define FT_STANDARD_RASTER_GET (GET_PIC(library)->ft_standard_raster)
#endif /* FT_CONFIG_OPTION_PIC */

View File

@ -24,35 +24,40 @@
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from sfdriver.c */
FT_Error FT_Create_Class_sfnt_services( FT_Library, FT_ServiceDescRec**);
void FT_Destroy_Class_sfnt_services( FT_Library, FT_ServiceDescRec*);
void FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec*);
void FT_Init_Class_sfnt_interface( FT_Library, SFNT_Interface*);
void FT_Init_Class_sfnt_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
void FT_Init_Class_sfnt_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
void FT_Init_Class_tt_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
void FT_Init_Class_sfnt_service_sfnt_table( FT_Service_SFNT_TableRec*);
FT_Error ft_library_pic_alloc_sfnt_services( FT_Library, FT_ServiceDescRec**);
void ft_library_pic_free_sfnt_services( FT_Library, FT_ServiceDescRec*);
void ft_pic_init_sfnt_service_bdf( FT_Service_BDFRec*);
void ft_pic_init_sfnt_interface( FT_Library, SFNT_Interface*);
void ft_pic_init_sfnt_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
void ft_pic_init_sfnt_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
void ft_pic_init_tt_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
void ft_pic_init_sfnt_service_sfnt_table( FT_Service_SFNT_TableRec*);
/* forward declaration of PIC init functions from ttcmap.c */
FT_Error FT_Create_Class_tt_cmap_classes( FT_Library, TT_CMap_Class**);
void FT_Destroy_Class_tt_cmap_classes( FT_Library, TT_CMap_Class*);
FT_Error ft_library_pic_alloc_tt_cmap_classes( FT_Library, TT_CMap_Class**);
void ft_library_pic_free_tt_cmap_classes( FT_Library, TT_CMap_Class*);
void
sfnt_module_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->sfnt )
FT_PicTable pic_table = &library->pic_table;
FT_Memory memory = library->memory;
if ( pic_table->sfnt )
{
sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt;
sfntModulePIC* container = (sfntModulePIC*)pic_table->sfnt;
if(container->sfnt_services)
FT_Destroy_Class_sfnt_services(library, container->sfnt_services);
ft_library_pic_free_sfnt_services(library, container->sfnt_services);
container->sfnt_services = NULL;
if(container->tt_cmap_classes)
FT_Destroy_Class_tt_cmap_classes(library, container->tt_cmap_classes);
container->tt_cmap_classes = NULL;
{
ft_library_pic_free_tt_cmap_classes(library, container->tt_cmap_classes);
container->tt_cmap_classes = NULL;
}
FT_FREE( container );
pic_container->sfnt = NULL;
pic_table->sfnt = NULL;
}
}
@ -60,36 +65,40 @@
FT_Error
sfnt_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
sfntModulePIC* container;
FT_Memory memory = library->memory;
FT_PicTable pic_table = &library->pic_table;
FT_Error error = FT_Err_Ok;
FT_Memory memory = library->memory;
sfntModulePIC* container;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
if ( FT_NEW ( container ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
pic_container->sfnt = container;
pic_table->sfnt = container;
/* initialize pointer table - this is how the module usually expects this data */
error = FT_Create_Class_sfnt_services(library, &container->sfnt_services);
if(error)
error = ft_library_pic_alloc_sfnt_services(library, &container->sfnt_services);
if(error)
goto Exit;
error = FT_Create_Class_tt_cmap_classes(library, &container->tt_cmap_classes);
if(error)
error = ft_library_pic_alloc_tt_cmap_classes(library, &container->tt_cmap_classes);
if(error)
goto Exit;
FT_Init_Class_sfnt_service_glyph_dict(library, &container->sfnt_service_glyph_dict);
FT_Init_Class_sfnt_service_ps_name(library, &container->sfnt_service_ps_name);
FT_Init_Class_tt_service_get_cmap_info(library, &container->tt_service_get_cmap_info);
FT_Init_Class_sfnt_service_sfnt_table(&container->sfnt_service_sfnt_table);
ft_pic_init_sfnt_service_glyph_dict (library, &container->sfnt_service_glyph_dict);
ft_pic_init_sfnt_service_ps_name (library, &container->sfnt_service_ps_name);
ft_pic_init_tt_service_get_cmap_info(library, &container->tt_service_get_cmap_info);
ft_pic_init_sfnt_service_sfnt_table(&container->sfnt_service_sfnt_table);
#ifdef TT_CONFIG_OPTION_BDF
FT_Init_Class_sfnt_service_bdf(&container->sfnt_service_bdf);
ft_pic_init_sfnt_service_bdf (&container->sfnt_service_bdf);
#endif
FT_Init_Class_sfnt_interface(library, &container->sfnt_interface);
ft_pic_init_sfnt_interface(library, &container->sfnt_interface);
Exit:
if(error)
sfnt_module_class_pic_free(library);
return error;
}

View File

@ -65,7 +65,7 @@ typedef struct sfntModulePIC_
SFNT_Interface sfnt_interface;
} sfntModulePIC;
#define GET_PIC(lib) ((sfntModulePIC*)((lib)->pic_container.sfnt))
#define GET_PIC(lib) ((sfntModulePIC*)((lib)->pic_table.sfnt))
#define FT_SFNT_SERVICES_GET (GET_PIC(library)->sfnt_services)
#define FT_SFNT_SERVICE_GLYPH_DICT_GET (GET_PIC(library)->sfnt_service_glyph_dict)
#define FT_SFNT_SERVICE_PS_NAME_GET (GET_PIC(library)->sfnt_service_ps_name)

View File

@ -3339,14 +3339,14 @@
#else /*FT_CONFIG_OPTION_PIC*/
void FT_Destroy_Class_tt_cmap_classes(FT_Library library, TT_CMap_Class* clazz)
void ft_library_pic_free_tt_cmap_classes(FT_Library library, TT_CMap_Class* clazz)
{
FT_Memory memory = library->memory;
if ( clazz )
FT_FREE( clazz );
}
FT_Error FT_Create_Class_tt_cmap_classes(FT_Library library, TT_CMap_Class** output_class)
FT_Error ft_library_pic_alloc_tt_cmap_classes(FT_Library library, TT_CMap_Class** output_class)
{
TT_CMap_Class* clazz;
TT_CMap_ClassRec* recs;
@ -3367,7 +3367,7 @@
#undef TTCMAPCITEM
#define TTCMAPCITEM(a) \
FT_Init_Class_##a(&recs[i]); \
ft_pic_init_##a(&recs[i]); \
clazz[i] = &recs[i]; \
i++;
#include "ttcmapc.h"

View File

@ -77,7 +77,7 @@ FT_BEGIN_HEADER
charvariant_list_,variantchar_list_, \
format_, validate_, get_cmap_info_) \
void \
FT_Init_Class_##class_( TT_CMap_ClassRec* clazz ) \
ft_pic_init_##class_( TT_CMap_ClassRec* clazz ) \
{ \
clazz->clazz.size = size_; \
clazz->clazz.init = init_; \

View File

@ -24,20 +24,23 @@
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftgrays.c */
void FT_Init_Class_ft_grays_raster(FT_Raster_Funcs*);
void ft_pic_init_ft_grays_raster(FT_Raster_Funcs*);
void
ft_smooth_renderer_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->smooth )
FT_PicTable pic_table = &library->pic_table;
FT_Memory memory = library->memory;
if ( pic_table->smooth )
{
SmoothPIC* container = (SmoothPIC*)pic_container->smooth;
SmoothPIC* container = (SmoothPIC*)pic_table->smooth;
if(--container->ref_count)
return;
FT_FREE( container );
pic_container->smooth = NULL;
pic_table->smooth = NULL;
}
}
@ -45,31 +48,32 @@
FT_Error
ft_smooth_renderer_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
SmoothPIC* container;
FT_Memory memory = library->memory;
FT_PicTable pic_table = &library->pic_table;
FT_Error error = FT_Err_Ok;
FT_Memory memory = library->memory;
SmoothPIC* container;
/* since this function also serve smooth_lcd and smooth_lcdv renderers,
it implements reference counting */
if(pic_container->smooth)
if(pic_table->smooth)
{
((SmoothPIC*)pic_container->smooth)->ref_count++;
((SmoothPIC*)pic_table->smooth)->ref_count++;
return error;
}
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
if ( FT_NEW ( container ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
pic_container->smooth = container;
pic_table->smooth = container;
container->ref_count = 1;
/* initialize pointer table - this is how the module usually expects this data */
FT_Init_Class_ft_grays_raster(&container->ft_grays_raster);
ft_pic_init_ft_grays_raster(&container->ft_grays_raster);
/*Exit:*/
if(error)
ft_smooth_renderer_class_pic_free(library);
return error;
}

View File

@ -35,7 +35,7 @@ FT_BEGIN_HEADER
FT_Raster_Funcs ft_grays_raster;
} SmoothPIC;
#define GET_PIC(lib) ((SmoothPIC*)((lib)->pic_container.smooth))
#define GET_PIC(lib) ((SmoothPIC*)((lib)->pic_table.smooth))
#define FT_GRAYS_RASTER_GET (GET_PIC(library)->ft_grays_raster)
#endif /* FT_CONFIG_OPTION_PIC */

View File

@ -24,53 +24,52 @@
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ttdriver.c */
FT_Error FT_Create_Class_tt_services( FT_Library, FT_ServiceDescRec**);
void FT_Destroy_Class_tt_services( FT_Library, FT_ServiceDescRec*);
void FT_Init_Class_tt_service_gx_multi_masters(FT_Service_MultiMastersRec*);
void FT_Init_Class_tt_service_truetype_glyf(FT_Service_TTGlyfRec*);
FT_Error ft_library_pic_alloc_tt_services( FT_Library, FT_ServiceDescRec**);
void ft_library_pic_free_tt_services( FT_Library, FT_ServiceDescRec*);
void ft_pic_init_tt_service_gx_multi_masters(FT_Service_MultiMastersRec*);
void ft_pic_init_tt_service_truetype_glyf(FT_Service_TTGlyfRec*);
void
tt_driver_class_pic_free( FT_Library library )
static void
pic_tt_driver_done( void* data, FT_PicTable pic )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->truetype )
TTModulePIC* container = (TTModulePIC*) data;
if (container->tt_services)
{
TTModulePIC* container = (TTModulePIC*)pic_container->truetype;
if(container->tt_services)
FT_Destroy_Class_tt_services(library, container->tt_services);
ft_library_pic_free_tt_services(pic->library, container->tt_services);
container->tt_services = NULL;
FT_FREE( container );
pic_container->truetype = NULL;
}
}
static FT_Error
pic_tt_driver_init( void* data, FT_PicTable pic )
{
TTModulePIC* container = (TTModulePIC*) data;
FT_Error error;
error = ft_library_pic_alloc_tt_services(pic->library, &container->tt_services);
if (error)
goto Exit;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
ft_pic_init_tt_service_gx_multi_masters(&container->tt_service_gx_multi_masters);
#endif
ft_pic_init_tt_service_truetype_glyf(&container->tt_service_truetype_glyf);
Exit:
return error;
}
FT_Error
tt_driver_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
TTModulePIC* container;
FT_Memory memory = library->memory;
FT_PicTable pic_table = &library->pic_table;
/* 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->truetype = container;
/* initialize pointer table - this is how the module usually expects this data */
error = FT_Create_Class_tt_services(library, &container->tt_services);
if(error)
goto Exit;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_Init_Class_tt_service_gx_multi_masters(&container->tt_service_gx_multi_masters);
#endif
FT_Init_Class_tt_service_truetype_glyf(&container->tt_service_truetype_glyf);
Exit:
if(error)
tt_driver_class_pic_free(library);
return error;
return ft_pic_table_init_data( pic_table,
pic_table->truetype,
sizeof(TTModulePIC),
pic_tt_driver_init,
pic_tt_driver_done );
}
#endif /* FT_CONFIG_OPTION_PIC */

View File

@ -42,7 +42,7 @@ FT_BEGIN_HEADER
FT_Service_TTGlyfRec tt_service_truetype_glyf;
} TTModulePIC;
#define GET_PIC(lib) ((TTModulePIC*)((lib)->pic_container.truetype))
#define GET_PIC(lib) ((TTModulePIC*)((lib)->pic_table.truetype))
#define FT_TT_SERVICES_GET (GET_PIC(library)->tt_services)
#define FT_TT_SERVICE_GX_MULTI_MASTERS_GET (GET_PIC(library)->tt_service_gx_multi_masters)
#define FT_TT_SERVICE_TRUETYPE_GLYF_GET (GET_PIC(library)->tt_service_truetype_glyf)