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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
diff --git a/ChangeLog b/ChangeLog
index e973ff8..3a35eed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
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>
+
Extract width parsing from Type 1 parser.
Duplicate the fast advance width calculations from the old parser.
diff --git a/devel/ftoption.h b/devel/ftoption.h
index 11a2d1f..fadda13 100644
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -745,6 +745,16 @@ FT_BEGIN_HEADER
/*************************************************************************/
+ /* */
+ /* 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 ****/
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index 10b9c64..3d5e5a4 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -754,6 +754,16 @@ FT_BEGIN_HEADER
/*************************************************************************/
+ /* */
+ /* 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 ****/
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index 96b2f1f..26652f8 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 82be440..086e889 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 16e887d..52f9e99 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 7244205..a88bcb7 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 )
{
@@ -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;
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index 61d2462..03183c8 100644
--- 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 */
diff --git a/src/psaux/t1decode.h b/src/psaux/t1decode.h
index 420d120..879f8f9 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 53f89b2..e50d7a5 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;