From dff40d03dff05734b8bf026716b780688f89e830 Mon Sep 17 00:00:00 2001 From: Ewald Hew Date: Thu, 12 Oct 2017 18:13:21 +0800 Subject: [PATCH] Add T1_CONFIG_OPTION_OLD_ENGINE configuration option. This controls whether the old Type 1 engine gets compiled into FreeType. It is disabled by default. * devel/ftoption.h, include/freetype/config/ftoption.h (T1_CONFIG_OPTION_OLD_ENGINE): New macro. * include/freetype/internal/psaux.h (PS_Decoder): Remove unused field. * include/freetype/internal/psaux.h, src/cid/cidgload.c (cid_load_glyph), src/psaux/psauxmod.c, src/psaux/psobjs.c (ps_builder_add_point), src/psaux/t1decode.c (t1_lookup_glyph_by_stdcharcode, t1_decoder_parse_glyph, t1operator_seac, t1_decoder_parse_charstrings), src/psaux/t1decode.h, src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Surround relevant code with macro. Minor code changes. --- ChangeLog | 20 ++++++++++++++++++++ devel/ftoption.h | 10 ++++++++++ include/freetype/config/ftoption.h | 10 ++++++++++ include/freetype/internal/psaux.h | 6 +++--- src/cid/cidgload.c | 5 ++++- src/psaux/psauxmod.c | 3 +++ src/psaux/psobjs.c | 7 ++++++- src/psaux/t1decode.c | 21 +++++++++++++-------- src/psaux/t1decode.h | 3 +++ src/type1/t1gload.c | 8 ++++++-- 10 files changed, 78 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index e973ff8bf..3a35eedd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2017-10-12 Ewald Hew + + Add T1_CONFIG_OPTION_OLD_ENGINE configuration option. + + This controls whether the old Type 1 engine gets compiled into FreeType. + It is disabled by default. + + * devel/ftoption.h, include/freetype/config/ftoption.h + (T1_CONFIG_OPTION_OLD_ENGINE): New macro. + + * include/freetype/internal/psaux.h (PS_Decoder): Remove unused field. + * include/freetype/internal/psaux.h, src/cid/cidgload.c + (cid_load_glyph), src/psaux/psauxmod.c, src/psaux/psobjs.c + (ps_builder_add_point), src/psaux/t1decode.c + (t1_lookup_glyph_by_stdcharcode, t1_decoder_parse_glyph, + t1operator_seac, t1_decoder_parse_charstrings), src/psaux/t1decode.h, + src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Surround + relevant code with macro. + Minor code changes. + 2017-10-12 Ewald Hew Extract width parsing from Type 1 parser. diff --git a/devel/ftoption.h b/devel/ftoption.h index 11a2d1f49..fadda13a6 100644 --- a/devel/ftoption.h +++ b/devel/ftoption.h @@ -744,6 +744,16 @@ FT_BEGIN_HEADER #undef T1_CONFIG_OPTION_NO_MM_SUPPORT + /*************************************************************************/ + /* */ + /* T1_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe Type 1 */ + /* engine gets compiled into FreeType. If defined, it is possible to */ + /* switch between the two engines using the `hinting-engine' property of */ + /* the type1 driver module. */ + /* */ +/* #define T1_CONFIG_OPTION_OLD_ENGINE */ + + /*************************************************************************/ /*************************************************************************/ /**** ****/ diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h index 10b9c644b..3d5e5a453 100644 --- a/include/freetype/config/ftoption.h +++ b/include/freetype/config/ftoption.h @@ -753,6 +753,16 @@ FT_BEGIN_HEADER #undef T1_CONFIG_OPTION_NO_MM_SUPPORT + /*************************************************************************/ + /* */ + /* T1_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe Type 1 */ + /* engine gets compiled into FreeType. If defined, it is possible to */ + /* switch between the two engines using the `hinting-engine' property of */ + /* the type1 driver module. */ + /* */ +/* #define T1_CONFIG_OPTION_OLD_ENGINE */ + + /*************************************************************************/ /*************************************************************************/ /**** ****/ diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h index 96b2f1f92..26652f888 100644 --- a/include/freetype/internal/psaux.h +++ b/include/freetype/internal/psaux.h @@ -655,8 +655,6 @@ FT_BEGIN_HEADER FT_Long* buildchar; FT_UInt len_buildchar; - void* t1_parse_callback; - } PS_Decoder; @@ -874,15 +872,17 @@ FT_BEGIN_HEADER void (*done)( T1_Decoder decoder ); +#ifdef T1_CONFIG_OPTION_OLD_ENGINE FT_Error (*parse_charstrings_old)( T1_Decoder decoder, FT_Byte* base, FT_UInt len ); - +#else FT_Error (*parse_metrics)( T1_Decoder decoder, FT_Byte* base, FT_UInt len ); +#endif FT_Error (*parse_charstrings)( PS_Decoder* decoder, diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c index 82be44008..086e88997 100644 --- a/src/cid/cidgload.c +++ b/src/cid/cidgload.c @@ -176,6 +176,7 @@ psaux->t1_decrypt( charstring, glyph_length, 4330 ); /* choose which renderer to use */ +#ifdef T1_CONFIG_OPTION_OLD_ENGINE if ( ( (PS_Driver)FT_FACE_DRIVER( face ) )->hinting_engine == FT_T1_HINTING_FREETYPE || decoder->builder.metrics_only ) @@ -183,11 +184,13 @@ decoder, charstring + cs_offset, glyph_length - cs_offset ); - else if ( decoder->builder.metrics_only ) +#else + if ( decoder->builder.metrics_only ) error = psaux->t1_decoder_funcs->parse_metrics( decoder, charstring + cs_offset, glyph_length - cs_offset ); +#endif else { PS_Decoder psdecoder; diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c index 16e887dec..52f9e9999 100644 --- a/src/psaux/psauxmod.c +++ b/src/psaux/psauxmod.c @@ -89,8 +89,11 @@ { t1_decoder_init, /* init */ t1_decoder_done, /* done */ +#ifdef T1_CONFIG_OPTION_OLD_ENGINE t1_decoder_parse_charstrings, /* parse_charstrings_old */ +#else t1_decoder_parse_metrics, /* parse_metrics */ +#endif cf2_decoder_parse_charstrings /* parse_charstrings */ }; diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c index 72442058c..a88bcb78c 100644 --- a/src/psaux/psobjs.c +++ b/src/psaux/psobjs.c @@ -2164,10 +2164,10 @@ FT_Vector* point = outline->points + outline->n_points; FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points; +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face ); -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE if ( !builder->is_t1 && driver->hinting_engine == FT_CFF_HINTING_FREETYPE ) { @@ -2175,6 +2175,10 @@ point->y = y >> 16; } else +#endif +#ifdef T1_CONFIG_OPTION_OLD_ENGINE +#ifndef CFF_CONFIG_OPTION_OLD_ENGINE + PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face ); #endif if ( builder->is_t1 && driver->hinting_engine == FT_T1_HINTING_FREETYPE ) @@ -2183,6 +2187,7 @@ point->y = FIXED_TO_INT( y ); } else +#endif { /* cf2_decoder_parse_charstrings uses 16.16 coordinates */ point->x = x >> 10; diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c index 61d246269..03183c8e0 100644 --- a/src/psaux/t1decode.c +++ b/src/psaux/t1decode.c @@ -158,6 +158,7 @@ } +#ifdef T1_CONFIG_OPTION_OLD_ENGINE /*************************************************************************/ /* */ /* */ @@ -207,6 +208,15 @@ } + /* parse a single Type 1 glyph */ + FT_LOCAL_DEF( FT_Error ) + t1_decoder_parse_glyph( T1_Decoder decoder, + FT_UInt glyph ) + { + return decoder->parse_callback( decoder, glyph ); + } + + /*************************************************************************/ /* */ /* */ @@ -1628,6 +1638,8 @@ return FT_THROW( Stack_Underflow ); } +#else /* T1_CONFIG_OPTION_OLD_ENGINE */ + /*************************************************************************/ /* */ /* */ @@ -1905,14 +1917,7 @@ Stack_Underflow: return FT_THROW( Stack_Underflow ); } - - /* parse a single Type 1 glyph */ - FT_LOCAL_DEF( FT_Error ) - t1_decoder_parse_glyph( T1_Decoder decoder, - FT_UInt glyph ) - { - return decoder->parse_callback( decoder, glyph ); - } +#endif /* T1_CONFIG_OPTION_OLD_ENGINE */ /* initialize T1 decoder */ diff --git a/src/psaux/t1decode.h b/src/psaux/t1decode.h index 420d120ff..879f8f999 100644 --- a/src/psaux/t1decode.h +++ b/src/psaux/t1decode.h @@ -35,6 +35,7 @@ FT_BEGIN_HEADER t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder, FT_Int charcode ); +#ifdef T1_CONFIG_OPTION_OLD_ENGINE FT_LOCAL( FT_Error ) t1_decoder_parse_glyph( T1_Decoder decoder, FT_UInt glyph_index ); @@ -43,10 +44,12 @@ FT_BEGIN_HEADER t1_decoder_parse_charstrings( T1_Decoder decoder, FT_Byte* base, FT_UInt len ); +#else FT_LOCAL( FT_Error ) t1_decoder_parse_metrics( T1_Decoder decoder, FT_Byte* charstring_base, FT_UInt charstring_len ); +#endif FT_LOCAL( FT_Error ) t1_decoder_init( T1_Decoder decoder, diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c index 53f89b230..e50d7a5f6 100644 --- a/src/type1/t1gload.c +++ b/src/type1/t1gload.c @@ -58,8 +58,9 @@ face->root.internal->incremental_interface; #endif +#ifdef T1_CONFIG_OPTION_OLD_ENGINE PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face ); - +#endif decoder->font_matrix = type1->font_matrix; decoder->font_offset = type1->font_offset; @@ -84,17 +85,20 @@ if ( !error ) { /* choose which renderer to use */ +#ifdef T1_CONFIG_OPTION_OLD_ENGINE if ( driver->hinting_engine == FT_T1_HINTING_FREETYPE || decoder->builder.metrics_only ) error = decoder_funcs->parse_charstrings_old( decoder, (FT_Byte*)char_string->pointer, (FT_UInt)char_string->length ); - else if ( decoder->builder.metrics_only ) +#else + if ( decoder->builder.metrics_only ) error = decoder_funcs->parse_metrics( decoder, (FT_Byte*)char_string->pointer, (FT_UInt)char_string->length ); +#endif else { CFF_SubFontRec subfont;