ref: dff40d03dff05734b8bf026716b780688f89e830
parent: 78df3c27b651e3de068437ac35ee2214849badb9
author: Ewald Hew <[email protected]>
date: Thu Oct 12 14:13:21 EDT 2017
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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
2017-10-12 Ewald Hew <[email protected]>
+ 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 <[email protected]>
+
Extract width parsing from Type 1 parser.
Duplicate the fast advance width calculations from the old parser.
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -745,6 +745,16 @@
/*************************************************************************/
+ /* */
+ /* 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 */
+
+
+ /*************************************************************************/
/*************************************************************************/
/**** ****/
/**** C F F D R I V E R C O N F I G U R A T I O N ****/
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -754,6 +754,16 @@
/*************************************************************************/
+ /* */
+ /* 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 */
+
+
+ /*************************************************************************/
/*************************************************************************/
/**** ****/
/**** C F F D R I V E R C O N F I G U R A T I O N ****/
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -655,8 +655,6 @@
FT_Long* buildchar;
FT_UInt len_buildchar;
- void* t1_parse_callback;
-
} PS_Decoder;
@@ -874,15 +872,17 @@
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,
--- 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;
--- 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 */
};
--- 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 )
{
@@ -2176,6 +2176,10 @@
}
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;
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -158,6 +158,7 @@
}
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
/*************************************************************************/
/* */
/* <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> */
@@ -1628,6 +1638,8 @@
return FT_THROW( Stack_Underflow );
}
+#else /* T1_CONFIG_OPTION_OLD_ENGINE */
+
/*************************************************************************/
/* */
/* <Function> */
@@ -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 */
--- a/src/psaux/t1decode.h
+++ b/src/psaux/t1decode.h
@@ -35,6 +35,7 @@
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 @@
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,
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -58,9 +58,10 @@
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,6 +85,7 @@
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(
@@ -90,11 +92,13 @@
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;