ref: edacde60e3974371dbab156c2d2b06b3f000e4b2
parent: 9578e07a83a8cb12fba360948b264796ec607f83
author: Ewald Hew <[email protected]>
date: Sun Sep 24 18:20:38 EDT 2017
Add new service for inter-module calls. NOTE: Does not compile! This is to allow CFF functions moved to `psaux' to call functions declared in `src/cff/cffload.h'. * include/freetype/internal/services/svcfftl.h: New file, setting up a `CFFLoad' service. * include/freetype/internal/ftserv.h (FT_DEFINE_SERVICEDESCREC10, FT_DEFINE_SERVICEDESCREC): New macros. (FT_SERVICE_CFF_TABLE_LOAD_H): New macro. * src/cff/cffdrivr.c, src/cff/cffpic.h: Register the new service. * src/cff/cfftypes.h (CFF_FontRec), src/psaux/cf2font.h (CF2_FontRec): Add service interface. * src/cff/cffobjs.c, src/psaux/cf2font.c, src/psaux/cf2ft.c, src/psaux/cf2intrp.c, src/psaux/cffdecode.c: Use the new service.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
2017-09-24 Ewald Hew <[email protected]>
+ [psaux, cff] Add new service for inter-module calls.
+
+ NOTE: Does not compile!
+
+ This is to allow CFF functions moved to `psaux' to call functions
+ declared in `src/cff/cffload.h'.
+
+ * include/freetype/internal/services/svcfftl.h: New file, setting up
+ a `CFFLoad' service.
+
+ * include/freetype/internal/ftserv.h (FT_DEFINE_SERVICEDESCREC10,
+ FT_DEFINE_SERVICEDESCREC): New macros.
+ (FT_SERVICE_CFF_TABLE_LOAD_H): New macro.
+
+ * src/cff/cffdrivr.c, src/cff/cffpic.h: Register the new service.
+
+ * src/cff/cfftypes.h (CFF_FontRec), src/psaux/cf2font.h
+ (CF2_FontRec): Add service interface.
+
+ * src/cff/cffobjs.c, src/psaux/cf2font.c, src/psaux/cf2ft.c,
+ src/psaux/cf2intrp.c, src/psaux/cffdecode.c: Use the new service.
+
+2017-09-24 Ewald Hew <[email protected]>
+
[psaux, cff] Add callbacks for inter-module calls.
NOTE: Does not compile!
--- a/include/freetype/internal/ftserv.h
+++ b/include/freetype/internal/ftserv.h
@@ -330,6 +330,32 @@
{ NULL, NULL } \
};
+#define FT_DEFINE_SERVICEDESCREC10( class_, \
+ serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2, \
+ serv_id_3, serv_data_3, \
+ serv_id_4, serv_data_4, \
+ serv_id_5, serv_data_5, \
+ serv_id_6, serv_data_6, \
+ serv_id_7, serv_data_7, \
+ serv_id_8, serv_data_8, \
+ serv_id_9, serv_data_9, \
+ serv_id_10, serv_data_10) \
+ static const FT_ServiceDescRec class_[] = \
+ { \
+ { serv_id_1, serv_data_1 }, \
+ { serv_id_2, serv_data_2 }, \
+ { serv_id_3, serv_data_3 }, \
+ { serv_id_4, serv_data_4 }, \
+ { serv_id_5, serv_data_5 }, \
+ { serv_id_6, serv_data_6 }, \
+ { serv_id_7, serv_data_7 }, \
+ { serv_id_8, serv_data_8 }, \
+ { serv_id_9, serv_data_9 }, \
+ { serv_id_10, serv_data_10 }, \
+ { NULL, NULL } \
+ };
+
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICEDESCREC1( class_, \
@@ -755,6 +781,68 @@
return FT_Err_Ok; \
}
+#define FT_DEFINE_SERVICEDESCREC10( class_, \
+ serv_id_1, serv_data_1, \
+ serv_id_2, serv_data_2, \
+ serv_id_3, serv_data_3, \
+ serv_id_4, serv_data_4, \
+ serv_id_5, serv_data_5, \
+ serv_id_6, serv_data_6, \
+ serv_id_7, serv_data_7, \
+ serv_id_8, serv_data_8, \
+ serv_id_9, serv_data_9, \
+ serv_id_10, serv_data_10 ) \
+ void \
+ FT_Destroy_Class_ ## class_( FT_Library library, \
+ FT_ServiceDescRec* clazz ) \
+ { \
+ FT_Memory memory = library->memory; \
+ \
+ \
+ if ( clazz ) \
+ FT_FREE( clazz ); \
+ } \
+ \
+ FT_Error \
+ FT_Create_Class_ ## class_( FT_Library library, \
+ FT_ServiceDescRec** output_class) \
+ { \
+ FT_ServiceDescRec* clazz = NULL; \
+ FT_Error error; \
+ FT_Memory memory = library->memory; \
+ \
+ \
+ if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 11 ) ) \
+ return error; \
+ \
+ clazz[0].serv_id = serv_id_1; \
+ clazz[0].serv_data = serv_data_1; \
+ clazz[1].serv_id = serv_id_2; \
+ clazz[1].serv_data = serv_data_2; \
+ clazz[2].serv_id = serv_id_3; \
+ clazz[2].serv_data = serv_data_3; \
+ clazz[3].serv_id = serv_id_4; \
+ clazz[3].serv_data = serv_data_4; \
+ clazz[4].serv_id = serv_id_5; \
+ clazz[4].serv_data = serv_data_5; \
+ clazz[5].serv_id = serv_id_6; \
+ clazz[5].serv_data = serv_data_6; \
+ clazz[6].serv_id = serv_id_7; \
+ clazz[6].serv_data = serv_data_7; \
+ clazz[7].serv_id = serv_id_8; \
+ clazz[7].serv_data = serv_data_8; \
+ clazz[8].serv_id = serv_id_9; \
+ clazz[8].serv_data = serv_data_9; \
+ clazz[9].serv_id = serv_id_10; \
+ clazz[9].serv_data = serv_data_10; \
+ clazz[10].serv_id = NULL; \
+ clazz[10].serv_data = NULL; \
+ \
+ *output_class = clazz; \
+ \
+ return FT_Err_Ok; \
+ }
+
#endif /* FT_CONFIG_OPTION_PIC */
@@ -916,7 +1004,7 @@
#define FT_SERVICE_WINFNT_H <freetype/internal/services/svwinfnt.h>
#define FT_SERVICE_FONT_FORMAT_H <freetype/internal/services/svfntfmt.h>
#define FT_SERVICE_TRUETYPE_GLYF_H <freetype/internal/services/svttglyf.h>
-
+#define FT_SERVICE_CFF_TABLE_LOAD_H <freetype/internal/services/svcfftl.h>
/* */
FT_END_HEADER
--- /dev/null
+++ b/include/freetype/internal/services/svcfftl.h
@@ -1,0 +1,94 @@
+#ifndef SVCFFTL_H_
+#define SVCFFTL_H_
+
+#include FT_INTERNAL_SERVICE_H
+
+
+FT_BEGIN_HEADER
+
+
+#define FT_SERVICE_ID_CFF_LOAD "cff-load"
+
+
+ typedef FT_UShort
+ (*FT_Get_Standard_Encoding_Func)( FT_UInt charcode );
+
+ typedef FT_Error
+ (*FT_Load_Private_Dict_Func)( CFF_Font font,
+ CFF_SubFont subfont,
+ FT_UInt lenNDV,
+ FT_Fixed* NDV );
+
+ typedef FT_Byte
+ (*FT_FD_Select_Get_Func)( CFF_FDSelect fdselect,
+ FT_UInt glyph_index );
+
+ typedef FT_Bool
+ (*FT_Blend_Check_Vector_Func)( CFF_Blend blend,
+ FT_UInt vsindex,
+ FT_UInt lenNDV,
+ FT_Fixed* NDV );
+
+ typedef FT_Error
+ (*FT_Blend_Build_Vector_Func)( CFF_Blend blend,
+ FT_UInt vsindex,
+ FT_UInt lenNDV,
+ FT_Fixed* NDV );
+
+
+ FT_DEFINE_SERVICE( CFFLoad )
+ {
+ FT_Get_Standard_Encoding_Func get_standard_encoding;
+ FT_Load_Private_Dict_Func load_private_dict;
+ FT_FD_Select_Get_Func fd_select_get;
+ FT_Blend_Check_Vector_Func blend_check_vector;
+ FT_Blend_Build_Vector_Func blend_build_vector;
+ };
+
+
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FT_DEFINE_SERVICE_CFFLOADREC( class_, \
+ get_standard_encoding_, \
+ load_private_dict_, \
+ fd_select_get_, \
+ blend_check_vector_, \
+ blend_build_vector_ ) \
+ static const FT_Service_CFFLoadRec class_ = \
+ { \
+ get_standard_encoding_, \
+ load_private_dict_, \
+ fd_select_get_, \
+ blend_check_vector_, \
+ blend_build_vector_ \
+ };
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DEFINE_SERVICE_CFFLOADREC( class_, \
+ get_standard_encoding_, \
+ load_private_dict_, \
+ fd_select_get_, \
+ blend_check_vector_, \
+ blend_build_vector_ ) \
+ void \
+ FT_Init_Class_ ## class_( FT_Service_CFFLoadRec* clazz ) \
+ { \
+ clazz->get_standard_encoding = get_standard_encoding_; \
+ clazz->load_private_dict = load_private_dict_; \
+ clazz->fd_select_get = fd_select_get_; \
+ clazz->blend_check_vector = blend_check_vector_; \
+ clazz->blend_build_vector = blend_build_vector_; \
+ }
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+
+
+
+FT_END_HEADER
+
+#endif
+
+
+/* END */
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -25,6 +25,7 @@
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_TT_CMAP_H
+#include FT_SERVICE_CFF_TABLE_LOAD_H
#include "cffdrivr.h"
#include "cffgload.h"
@@ -1088,6 +1089,21 @@
#endif
+ /*
+ * CFFLOAD SERVICE
+ *
+ */
+
+ FT_DEFINE_SERVICE_CFFLOADREC(
+ cff_service_cff_load,
+
+ (FT_Get_Standard_Encoding_Func) cff_get_standard_encoding,
+ (FT_Load_Private_Dict_Func) cff_load_private_dict,
+ (FT_FD_Select_Get_Func) cff_fd_select_get,
+ (FT_Blend_Check_Vector_Func) cff_blend_check_vector,
+ (FT_Blend_Build_Vector_Func) cff_blend_build_vector
+ )
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -1102,7 +1118,7 @@
#if !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES && \
defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_DEFINE_SERVICEDESCREC9(
+ FT_DEFINE_SERVICEDESCREC10(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
@@ -1113,10 +1129,11 @@
FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
- FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
+ FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
+ FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES
- FT_DEFINE_SERVICEDESCREC7(
+ FT_DEFINE_SERVICEDESCREC8(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
@@ -1125,10 +1142,11 @@
FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
- FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
+ FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
+ FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_DEFINE_SERVICEDESCREC8(
+ FT_DEFINE_SERVICEDESCREC9(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
@@ -1138,10 +1156,11 @@
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
- FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
+ FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
+ FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#else
- FT_DEFINE_SERVICEDESCREC6(
+ FT_DEFINE_SERVICEDESCREC7(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
@@ -1149,7 +1168,8 @@
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
- FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
+ FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
+ FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#endif
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -496,6 +496,7 @@
FT_Service_PsCMaps psnames;
PSHinter_Service pshinter;
PSAux_Service psaux;
+ FT_Service_CFFLoad cffload;
FT_Bool pure_cff = 1;
FT_Bool cff2 = 0;
FT_Bool sfnt_format = 0;
@@ -526,6 +527,8 @@
}
face->psaux = psaux;
+ FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD );
+
FT_TRACE2(( "CFF driver\n" ));
/* create input stream from resource */
@@ -627,6 +630,7 @@
cff->pshinter = pshinter;
cff->psnames = psnames;
+ cff->cffload = cffload;
cffface->face_index = face_index & 0xFFFF;
--- a/src/cff/cffpic.h
+++ b/src/cff/cffpic.h
@@ -22,7 +22,6 @@
#include FT_INTERNAL_PIC_H
-
#ifndef FT_CONFIG_OPTION_PIC
#define CFF_SERVICE_PS_INFO_GET cff_service_ps_info
@@ -34,6 +33,7 @@
#define CFF_SERVICES_GET cff_services
#define CFF_SERVICE_MULTI_MASTERS_GET cff_service_multi_masters
#define CFF_SERVICE_METRICS_VAR_GET cff_service_metrics_variations
+#define CFF_SERVICE_CFF_LOAD_GET cff_service_cff_load
#define CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec
#define CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec
#define CFF_FIELD_HANDLERS_GET cff_field_handlers
@@ -65,6 +65,7 @@
FT_Service_PropertiesRec cff_service_properties;
FT_Service_MultiMastersRec cff_service_multi_masters;
FT_Service_MetricsVariationsRec cff_service_metrics_variations;
+ FT_Service_CFFLoadRec cff_service_cff_load;
FT_CMap_ClassRec cff_cmap_encoding_class_rec;
FT_CMap_ClassRec cff_cmap_unicode_class_rec;
@@ -92,6 +93,8 @@
( GET_PIC( library )->cff_service_multi_masters )
#define CFF_SERVICE_METRICS_VAR_GET \
( GET_PIC( library )->cff_service_metrics_variations )
+#define CFF_SERVICE_CFF_LOAD_GET \
+ ( GET_PIC( library )->cff_service_cff_load )
#define CFF_CMAP_ENCODING_CLASS_REC_GET \
( GET_PIC( library )->cff_cmap_encoding_class_rec )
#define CFF_CMAP_UNICODE_CLASS_REC_GET \
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -381,6 +381,9 @@
/* interface to Postscript Names service */
FT_Service_PsCMaps psnames;
+ /* interface to CFFLoad service */
+ const void* cffload;
+
/* since version 2.3.0 */
PS_FontInfoRec* font_info; /* font info dictionary */
--- a/src/psaux/cf2font.c
+++ b/src/psaux/cf2font.c
@@ -260,6 +260,7 @@
CF2_UInt lenNormalizedV = 0;
FT_Fixed* normalizedV = NULL;
+ FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)font->cffload;
/* clear previous error */
font->error = FT_Err_Ok;
@@ -287,16 +288,16 @@
if ( font->error )
return;
- if ( cff_blend_check_vector( &subFont->blend,
- subFont->private_dict.vsindex,
- lenNormalizedV,
- normalizedV ) )
+ if ( cffload->blend_check_vector( &subFont->blend,
+ subFont->private_dict.vsindex,
+ lenNormalizedV,
+ normalizedV ) )
{
/* blend has changed, reparse */
- cff_load_private_dict( decoder->cff,
- subFont,
- lenNormalizedV,
- normalizedV );
+ cffload->load_private_dict( decoder->cff,
+ subFont,
+ lenNormalizedV,
+ normalizedV );
needExtraSetup = TRUE;
}
#endif
--- a/src/psaux/cf2font.h
+++ b/src/psaux/cf2font.h
@@ -40,9 +40,10 @@
#define CF2FONT_H_
+#include FT_SERVICE_CFF_TABLE_LOAD_H
+
#include "cf2ft.h"
#include "cf2blues.h"
-#include "cffload.h"
FT_BEGIN_HEADER
@@ -111,6 +112,8 @@
/* counterclockwise winding */
CF2_BluesRec blues; /* computed zone data */
+
+ FT_Service_CFFLoad cffload; /* Pointer to cff functions */
};
--- a/src/psaux/cf2ft.c
+++ b/src/psaux/cf2ft.c
@@ -42,6 +42,7 @@
#include "cf2font.h"
#include "cf2error.h"
+#include FT_SERVICE_CFF_TABLE_LOAD_H
#define CF2_MAX_SIZE cf2_intToFixed( 2000 ) /* max ppem */
@@ -324,6 +325,7 @@
font = (CF2_Font)decoder->cff->cf2_instance.data;
font->memory = memory;
+ font->cffload = (FT_Service_CFFLoad)decoder->cff->cffload;
/* initialize a client outline, to be shared by each glyph rendered */
cf2_outline_init( &font->outline, font->memory, &font->error );
--- a/src/psaux/cf2intrp.c
+++ b/src/psaux/cf2intrp.c
@@ -38,6 +38,7 @@
#include "cf2ft.h"
#include FT_INTERNAL_DEBUG_H
+#include FT_SERVICE_CFF_TABLE_LOAD_H
#include "cf2glue.h"
#include "cf2font.h"
@@ -47,9 +48,7 @@
#include "cf2error.h"
-#include "cffload.h"
-
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -689,15 +688,15 @@
}
/* check cached blend vector */
- if ( cff_blend_check_vector( &font->blend,
- font->vsindex,
- font->lenNDV,
- font->NDV ) )
+ if ( font->cffload->blend_check_vector( &font->blend,
+ font->vsindex,
+ font->lenNDV,
+ font->NDV ) )
{
- lastError = cff_blend_build_vector( &font->blend,
- font->vsindex,
- font->lenNDV,
- font->NDV );
+ lastError = font->cffload->blend_build_vector( &font->blend,
+ font->vsindex,
+ font->lenNDV,
+ font->NDV );
if ( lastError )
goto exit;
}
--- a/src/psaux/cffdecode.c
+++ b/src/psaux/cffdecode.c
@@ -1,6 +1,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_SERVICE_H
+#include FT_SERVICE_CFF_TABLE_LOAD_H
#include "cffdecode.h"
#include "psobjs.h"
@@ -390,8 +392,8 @@
{
FT_UInt n;
FT_UShort glyph_sid;
+ FT_Service_CFFLoad cffload;
-
/* CID-keyed fonts don't have glyph names */
if ( !cff->charset.sids )
return -1;
@@ -400,8 +402,24 @@
if ( charcode < 0 || charcode > 255 )
return -1;
+#if 0
+ /* retrieve cffload from list of current modules */
+ FT_Service_CFFLoad cffload;
+ {
+ FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD );
+ if ( !cffload )
+ {
+ FT_ERROR(( "cff_lookup_glyph_by_stdcharcode:"
+ " the `cffload' module is not available\n" ));
+ return FT_THROW( Unimplemented_Feature );
+ }
+ }
+#endif
+
+ cffload = (FT_Service_CFFLoad)cff->cffload;
+
/* Get code to SID mapping from `cff_standard_encoding'. */
- glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode );
+ glyph_sid = cffload->get_standard_encoding( (FT_UInt)charcode );
for ( n = 0; n < cff->num_glyphs; n++ )
{
@@ -2271,11 +2289,12 @@
CFF_SubFont sub = &cff->top_font;
FT_Error error = FT_Err_Ok;
+ FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)cff->cffload;
/* manage CID fonts */
if ( cff->num_subfonts )
{
- FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index );
+ FT_Byte fd_index = cffload->fd_select_get( &cff->fd_select, glyph_index );
if ( fd_index >= cff->num_subfonts )