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.
This commit is contained in:
Ewald Hew 2017-10-12 18:13:21 +08:00
parent 78df3c27b6
commit dff40d03df
10 changed files with 78 additions and 15 deletions

View File

@ -1,3 +1,23 @@
2017-10-12 Ewald Hew <ewaldhew@gmail.com>
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 <ewaldhew@gmail.com> 2017-10-12 Ewald Hew <ewaldhew@gmail.com>
Extract width parsing from Type 1 parser. Extract width parsing from Type 1 parser.

View File

@ -744,6 +744,16 @@ FT_BEGIN_HEADER
#undef T1_CONFIG_OPTION_NO_MM_SUPPORT #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 */
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/**** ****/ /**** ****/

View File

@ -753,6 +753,16 @@ FT_BEGIN_HEADER
#undef T1_CONFIG_OPTION_NO_MM_SUPPORT #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 */
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/**** ****/ /**** ****/

View File

@ -655,8 +655,6 @@ FT_BEGIN_HEADER
FT_Long* buildchar; FT_Long* buildchar;
FT_UInt len_buildchar; FT_UInt len_buildchar;
void* t1_parse_callback;
} PS_Decoder; } PS_Decoder;
@ -874,15 +872,17 @@ FT_BEGIN_HEADER
void void
(*done)( T1_Decoder decoder ); (*done)( T1_Decoder decoder );
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
FT_Error FT_Error
(*parse_charstrings_old)( T1_Decoder decoder, (*parse_charstrings_old)( T1_Decoder decoder,
FT_Byte* base, FT_Byte* base,
FT_UInt len ); FT_UInt len );
#else
FT_Error FT_Error
(*parse_metrics)( T1_Decoder decoder, (*parse_metrics)( T1_Decoder decoder,
FT_Byte* base, FT_Byte* base,
FT_UInt len ); FT_UInt len );
#endif
FT_Error FT_Error
(*parse_charstrings)( PS_Decoder* decoder, (*parse_charstrings)( PS_Decoder* decoder,

View File

@ -176,6 +176,7 @@
psaux->t1_decrypt( charstring, glyph_length, 4330 ); psaux->t1_decrypt( charstring, glyph_length, 4330 );
/* choose which renderer to use */ /* choose which renderer to use */
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
if ( ( (PS_Driver)FT_FACE_DRIVER( face ) )->hinting_engine == if ( ( (PS_Driver)FT_FACE_DRIVER( face ) )->hinting_engine ==
FT_T1_HINTING_FREETYPE || FT_T1_HINTING_FREETYPE ||
decoder->builder.metrics_only ) decoder->builder.metrics_only )
@ -183,11 +184,13 @@
decoder, decoder,
charstring + cs_offset, charstring + cs_offset,
glyph_length - 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( error = psaux->t1_decoder_funcs->parse_metrics(
decoder, decoder,
charstring + cs_offset, charstring + cs_offset,
glyph_length - cs_offset ); glyph_length - cs_offset );
#endif
else else
{ {
PS_Decoder psdecoder; PS_Decoder psdecoder;

View File

@ -89,8 +89,11 @@
{ {
t1_decoder_init, /* init */ t1_decoder_init, /* init */
t1_decoder_done, /* done */ t1_decoder_done, /* done */
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
t1_decoder_parse_charstrings, /* parse_charstrings_old */ t1_decoder_parse_charstrings, /* parse_charstrings_old */
#else
t1_decoder_parse_metrics, /* parse_metrics */ t1_decoder_parse_metrics, /* parse_metrics */
#endif
cf2_decoder_parse_charstrings /* parse_charstrings */ cf2_decoder_parse_charstrings /* parse_charstrings */
}; };

View File

@ -2164,10 +2164,10 @@
FT_Vector* point = outline->points + outline->n_points; FT_Vector* point = outline->points + outline->n_points;
FT_Byte* control = (FT_Byte*)outline->tags + 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 ); PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
if ( !builder->is_t1 && if ( !builder->is_t1 &&
driver->hinting_engine == FT_CFF_HINTING_FREETYPE ) driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
{ {
@ -2175,6 +2175,10 @@
point->y = y >> 16; point->y = y >> 16;
} }
else 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 #endif
if ( builder->is_t1 && if ( builder->is_t1 &&
driver->hinting_engine == FT_T1_HINTING_FREETYPE ) driver->hinting_engine == FT_T1_HINTING_FREETYPE )
@ -2183,6 +2187,7 @@
point->y = FIXED_TO_INT( y ); point->y = FIXED_TO_INT( y );
} }
else else
#endif
{ {
/* cf2_decoder_parse_charstrings uses 16.16 coordinates */ /* cf2_decoder_parse_charstrings uses 16.16 coordinates */
point->x = x >> 10; point->x = x >> 10;

View File

@ -158,6 +158,7 @@
} }
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Function> */ /* <Function> */
@ -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 );
}
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Function> */ /* <Function> */
@ -1628,6 +1638,8 @@
return FT_THROW( Stack_Underflow ); return FT_THROW( Stack_Underflow );
} }
#else /* T1_CONFIG_OPTION_OLD_ENGINE */
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Function> */ /* <Function> */
@ -1905,14 +1917,7 @@
Stack_Underflow: Stack_Underflow:
return FT_THROW( Stack_Underflow ); return FT_THROW( Stack_Underflow );
} }
#endif /* T1_CONFIG_OPTION_OLD_ENGINE */
/* 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 );
}
/* initialize T1 decoder */ /* initialize T1 decoder */

View File

@ -35,6 +35,7 @@ FT_BEGIN_HEADER
t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder, t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder,
FT_Int charcode ); FT_Int charcode );
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
t1_decoder_parse_glyph( T1_Decoder decoder, t1_decoder_parse_glyph( T1_Decoder decoder,
FT_UInt glyph_index ); FT_UInt glyph_index );
@ -43,10 +44,12 @@ FT_BEGIN_HEADER
t1_decoder_parse_charstrings( T1_Decoder decoder, t1_decoder_parse_charstrings( T1_Decoder decoder,
FT_Byte* base, FT_Byte* base,
FT_UInt len ); FT_UInt len );
#else
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
t1_decoder_parse_metrics( T1_Decoder decoder, t1_decoder_parse_metrics( T1_Decoder decoder,
FT_Byte* charstring_base, FT_Byte* charstring_base,
FT_UInt charstring_len ); FT_UInt charstring_len );
#endif
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
t1_decoder_init( T1_Decoder decoder, t1_decoder_init( T1_Decoder decoder,

View File

@ -58,8 +58,9 @@
face->root.internal->incremental_interface; face->root.internal->incremental_interface;
#endif #endif
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face ); PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face );
#endif
decoder->font_matrix = type1->font_matrix; decoder->font_matrix = type1->font_matrix;
decoder->font_offset = type1->font_offset; decoder->font_offset = type1->font_offset;
@ -84,17 +85,20 @@
if ( !error ) if ( !error )
{ {
/* choose which renderer to use */ /* choose which renderer to use */
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
if ( driver->hinting_engine == FT_T1_HINTING_FREETYPE || if ( driver->hinting_engine == FT_T1_HINTING_FREETYPE ||
decoder->builder.metrics_only ) decoder->builder.metrics_only )
error = decoder_funcs->parse_charstrings_old( error = decoder_funcs->parse_charstrings_old(
decoder, decoder,
(FT_Byte*)char_string->pointer, (FT_Byte*)char_string->pointer,
(FT_UInt)char_string->length ); (FT_UInt)char_string->length );
else if ( decoder->builder.metrics_only ) #else
if ( decoder->builder.metrics_only )
error = decoder_funcs->parse_metrics( error = decoder_funcs->parse_metrics(
decoder, decoder,
(FT_Byte*)char_string->pointer, (FT_Byte*)char_string->pointer,
(FT_UInt)char_string->length ); (FT_UInt)char_string->length );
#endif
else else
{ {
CFF_SubFontRec subfont; CFF_SubFontRec subfont;