Fixes for rendering. The Type 1 advance width calculation passes null for glyph slot, etc, which can cause null pointer access in the new interpreter. Fall back to the old one for now. Fix the large glyph retry code and ensure hinting and scaling flags are set properly. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Add a check for metrics_only. Set the `force_scaling' flag. (T1_Parse_Glyph): Updated. (T1_Load_Glyph): Add `hinting' and `scaled' flags.
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
diff --git a/ChangeLog b/ChangeLog
index c41b9f2..5615f62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2017-09-25 Ewald Hew <ewaldhew@gmail.com>
+ [type1] Fixes for rendering.
+
+ The Type 1 advance width calculation passes null for glyph slot,
+ etc, which can cause null pointer access in the new interpreter.
+ Fall back to the old one for now.
+
+ Fix the large glyph retry code and ensure hinting and scaling flags
+ are set properly.
+
+ * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Add a
+ check for metrics_only.
+ Set the `force_scaling' flag.
+ (T1_Parse_Glyph): Updated.
+ (T1_Load_Glyph): Add `hinting' and `scaled' flags.
+
+2017-09-25 Ewald Hew <ewaldhew@gmail.com>
+
[psaux] Add missing objects (2/2).
Synthesize a `SubFont' object for Type 1 fonts. This is used in the
@@ -198,7 +215,7 @@
[psaux] Minor fix.
- Use `MultiMasters' service in `psaux' instead of a call to `cff'.
+ Use `MultiMasters' service in `psaux' instead of a call to `cff'.
The project builds if CFF_CONFIG_OPTION_OLD_ENGINE is not defined.
* src/psaux/cf2ft.c: Update includes.
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 56689de..b1020e9 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -59,7 +59,8 @@
static FT_Error
T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder,
FT_UInt glyph_index,
- FT_Data* char_string )
+ FT_Data* char_string,
+ FT_Bool* force_scaling )
{
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font type1 = &face->type1;
@@ -99,7 +100,8 @@
if ( !error )
{
/* choose which renderer to use */
- if ( driver->hinting_engine == FT_T1_HINTING_FREETYPE )
+ 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 );
@@ -117,7 +119,6 @@
(FT_Byte*)char_string->pointer,
(FT_ULong)char_string->length );
-#if 0 /* TODO(ewaldhew) */
/* Adobe's engine uses 16.16 numbers everywhere; */
/* as a consequence, glyphs larger than 2000ppem get rejected */
if ( FT_ERR_EQ( error, Glyph_Too_Big ) )
@@ -125,15 +126,14 @@
/* this time, we retry unhinted and scale up the glyph later on */
/* (the engine uses and sets the hardcoded value 0x10000 / 64 = */
/* 0x400 for both `x_scale' and `y_scale' in this case) */
- hinting = FALSE;
- force_scaling = TRUE;
- glyph->hint = hinting;
+ ((T1_GlyphSlot)decoder->builder.glyph)->hint = FALSE;
+
+ *force_scaling = TRUE;
error = decoder_funcs->parse_charstrings( &psdecoder,
(FT_Byte*)char_string->pointer,
(FT_ULong)char_string->length );
}
-#endif
}
}
@@ -170,8 +170,10 @@
FT_UInt glyph_index )
{
FT_Data glyph_data;
+ FT_Bool force_scaling = FALSE;
FT_Error error = T1_Parse_Glyph_And_Get_Char_String(
- decoder, glyph_index, &glyph_data );
+ decoder, glyph_index, &glyph_data,
+ &force_scaling );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -322,6 +324,8 @@
T1_DecoderRec decoder;
T1_Face face = (T1_Face)t1glyph->face;
FT_Bool hinting;
+ FT_Bool scaled;
+ FT_Bool force_scaling = FALSE;
T1_Font type1 = &face->type1;
PSAux_Service psaux = (PSAux_Service)face->psaux;
const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
@@ -369,7 +373,10 @@
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
+ scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
+ glyph->hint = hinting;
+ glyph->scaled = scaled;
t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
error = decoder_funcs->init( &decoder,
@@ -399,13 +406,15 @@
/* now load the unscaled outline */
error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,
- &glyph_data );
+ &glyph_data,
+ &force_scaling );
if ( error )
goto Exit;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
glyph_data_loaded = 1;
#endif
+ hinting = glyph->hint;
font_matrix = decoder.font_matrix;
font_offset = decoder.font_offset;
@@ -495,7 +504,7 @@
}
#endif
- if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
+ if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
{
/* scale the outline and the metrics */
FT_Int n;