Move creation of field `buildchar' of T1_DecoderRec out of `t1_decoder_init' and let the caller of `t1_decoder_init' take care of it. Call the finisher for T1_Decoder in `cid_face_compute_max_advance' and `T1_Compute_Max_Advance'. * freetype2/include/freetype/internal/psaux.h (T1_DecoderRec): Remove field `face', add `len_buildchar'. * freetype2/include/freetype/internal/t1types.h (T1_FaceRec): Add field `buildchar'. * freetype2/src/cid/cidgload.c (cid_face_compute_max_advance): Call finisher for T1_Decoder. (cid_slot_load_glyph): Do not ignore failure when initializing the T1_Decoder. * freetype2/src/psaux/t1decode.c (t1_decoder_parse_charstrings): Updated. (t1_decoder_init): Remove initialization of fields `buildchar' and `len_buildchar'. (t1_decoder_done): Remove deallocation of field `buildchar'. * freetype/src/type1/t1gload.c (T1_Compute_Max_Advance): Initialize T1_Decoder's `buildchar' and `len_buildchar'; call finisher for T1_Decoder. (T1_Load_Glyph): Initialize T1_Decoder's `buildchar' and `len_buildchar'; make sure to call finisher for T1_Decoder even in case of error. * freetype2/src/type1/t1load.c (T1_Open_Face): Allocate new field `buildchar' of T1_FaceRec. * freetype2/src/type1/t1objs.c (T1_Face_Done): Free new field `buildchar' of T1_FaceRec.
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 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
diff --git a/ChangeLog b/ChangeLog
index 07a39f0..7202363 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,42 @@
+2006-07-18 Jens Claudius <jens.claudius@yahoo.com>
+
+ Move creation of field `buildchar' of T1_DecoderRec out of
+ `t1_decoder_init' and let the caller of `t1_decoder_init' take care
+ of it.
+
+ Call the finisher for T1_Decoder in `cid_face_compute_max_advance'
+ and `T1_Compute_Max_Advance'.
+
+ * freetype2/include/freetype/internal/psaux.h (T1_DecoderRec):
+ Remove field `face', add `len_buildchar'.
+
+ * freetype2/include/freetype/internal/t1types.h (T1_FaceRec): Add
+ field `buildchar'.
+
+ * freetype2/src/cid/cidgload.c (cid_face_compute_max_advance): Call
+ finisher for T1_Decoder.
+ (cid_slot_load_glyph): Do not ignore failure when initializing the
+ T1_Decoder.
+
+ * freetype2/src/psaux/t1decode.c (t1_decoder_parse_charstrings):
+ Updated.
+ (t1_decoder_init): Remove initialization of fields `buildchar' and
+ `len_buildchar'.
+ (t1_decoder_done): Remove deallocation of field `buildchar'.
+
+ * freetype/src/type1/t1gload.c (T1_Compute_Max_Advance): Initialize
+ T1_Decoder's `buildchar' and `len_buildchar'; call finisher for
+ T1_Decoder.
+ (T1_Load_Glyph): Initialize T1_Decoder's `buildchar' and
+ `len_buildchar'; make sure to call finisher for T1_Decoder even in
+ case of error.
+
+ * freetype2/src/type1/t1load.c (T1_Open_Face): Allocate new field
+ `buildchar' of T1_FaceRec.
+
+ * freetype2/src/type1/t1objs.c (T1_Face_Done): Free new field
+ `buildchar' of T1_FaceRec.
+
2006-07-14 Jens Claudius <jens.claudius@yahoo.com>
* freetype2/include/freetype/internal/psaux.h: New macros
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index 4afd2b0..2586e95 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -687,8 +687,7 @@ FT_BEGIN_HEADER
T1_Decoder_FuncsRec funcs;
FT_Int* buildchar;
-
- T1_Face face;
+ FT_UInt len_buildchar;
} T1_DecoderRec;
diff --git a/include/freetype/internal/t1types.h b/include/freetype/internal/t1types.h
index eca91a7..3075571 100644
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -217,6 +217,7 @@ FT_BEGIN_HEADER
/* undocumented, optional: has the same meaning as len_buildchar */
/* for Type 2 fonts; manipulated by othersubrs 19, 24, and 25 */
FT_UInt len_buildchar;
+ FT_Int* buildchar;
/* since version 2.1 - interface to PostScript hinter */
const void* pshinter;
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index ed706ad..4815aba 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -230,6 +230,9 @@
if ( error )
return error;
+ /* TODO: initialize decoder.len_buildchar and decoder.buildchar */
+ /* if we ever support CID-keyed multiple master fonts */
+
decoder.builder.metrics_only = 1;
decoder.builder.load_points = 0;
@@ -245,6 +248,8 @@
*max_advance = decoder.builder.advance.x;
+ psaux->t1_decoder_funcs->done( &decoder );
+
return CID_Err_Ok;
}
@@ -295,17 +300,23 @@
FT_LOAD_TARGET_MODE( load_flags ),
cid_load_glyph );
- /* set up the decoder */
- decoder.builder.no_recurse = FT_BOOL(
- ( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ) );
+ if ( !error )
+ {
+ /* TODO: initialize decoder.len_buildchar and decoder.buildchar */
+ /* if we ever support CID-keyed multiple master fonts */
+
+ /* set up the decoder */
+ decoder.builder.no_recurse = FT_BOOL(
+ ( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ) );
- error = cid_load_glyph( &decoder, glyph_index );
+ error = cid_load_glyph( &decoder, glyph_index );
- font_matrix = decoder.font_matrix;
- font_offset = decoder.font_offset;
+ font_matrix = decoder.font_matrix;
+ font_offset = decoder.font_offset;
- /* save new glyph tables */
- psaux->t1_decoder_funcs->done( &decoder );
+ /* save new glyph tables */
+ psaux->t1_decoder_funcs->done( &decoder );
+ }
}
/* now, set the metrics -- this is rather simple, as */
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index bc799e4..4373d6f 100644
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -350,11 +350,14 @@
/* a font that reads BuildCharArray without setting */
/* its values first is buggy, but ... */
- if ( decoder->face->len_buildchar > 0 )
+ FT_ASSERT( ( decoder->len_buildchar == 0 ) ==
+ ( decoder->buildchar == NULL ) );
+
+ if ( decoder->len_buildchar > 0 )
memset( &decoder->buildchar[0],
0,
sizeof( decoder->buildchar[0] ) *
- decoder->face->len_buildchar );
+ decoder->len_buildchar );
FT_TRACE4(( "\nStart charstring\n" ));
@@ -839,7 +842,7 @@
idx = top[1];
- if ( idx < 0 || (FT_UInt) idx >= decoder->face->len_buildchar )
+ if ( idx < 0 || (FT_UInt) idx >= decoder->len_buildchar )
goto Unexpected_OtherSubr;
decoder->buildchar[idx] = top[0];
@@ -859,7 +862,7 @@
idx = top[0];
- if ( idx < 0 || (FT_UInt) idx >= decoder->face->len_buildchar )
+ if ( idx < 0 || (FT_UInt) idx >= decoder->len_buildchar )
goto Unexpected_OtherSubr;
top[0] = decoder->buildchar[idx];
@@ -987,14 +990,14 @@
#ifdef FT_DEBUG_LEVEL_TRACE
- if ( decoder->face->len_buildchar > 0 )
+ if ( decoder->len_buildchar > 0 )
{
FT_UInt i;
FT_TRACE4(( "BuildCharArray = [ " ));
- for ( i = 0; i < decoder->face->len_buildchar; ++i )
+ for ( i = 0; i < decoder->len_buildchar; ++i )
FT_TRACE4(( "%d ", decoder->buildchar[ i ] ));
FT_TRACE4(( "]\n" ));
@@ -1423,10 +1426,6 @@
FT_Render_Mode hint_mode,
T1_Decoder_Callback parse_callback )
{
- FT_Error error;
- FT_Memory memory = face->memory;
-
-
FT_MEM_ZERO( decoder, sizeof ( *decoder ) );
/* retrieve PSNames interface from list of current modules */
@@ -1445,20 +1444,12 @@
decoder->psnames = psnames;
}
- decoder->face = (T1_Face) face;
-
- if ( decoder->face->len_buildchar > 0 )
- {
- if ( FT_NEW_ARRAY( decoder->buildchar, decoder->face->len_buildchar ) )
- {
- FT_ERROR(( "t1_decoder_init: " ));
- FT_ERROR(( "cannot allocate memory for BuildCharArray\n" ));
- return error;
- }
- }
-
t1_builder_init( &decoder->builder, face, size, slot, hinting );
+ /* decoder->buildchar and decoder->len_buildchar have to be */
+ /* initialized by the caller since we cannot know the length */
+ /* of the BuildCharArray */
+
decoder->num_glyphs = (FT_UInt)face->num_glyphs;
decoder->glyph_names = glyph_names;
decoder->hint_mode = hint_mode;
@@ -1467,7 +1458,7 @@
decoder->funcs = t1_decoder_funcs;
- return 0;
+ return PSaux_Err_Ok;
}
@@ -1475,12 +1466,7 @@
FT_LOCAL_DEF( void )
t1_decoder_done( T1_Decoder decoder )
{
- FT_Memory memory = decoder->face->root.memory;
-
-
t1_builder_done( &decoder->builder );
-
- FT_FREE( decoder->buildchar );
}
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 804713f..7012b4a 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -155,6 +155,8 @@
PSAux_Service psaux = (PSAux_Service)face->psaux;
+ FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
+
*max_advance = 0;
/* initialize load decoder */
@@ -173,9 +175,12 @@
decoder.builder.metrics_only = 1;
decoder.builder.load_points = 0;
- decoder.num_subrs = type1->num_subrs;
- decoder.subrs = type1->subrs;
- decoder.subrs_len = type1->subrs_len;
+ decoder.num_subrs = type1->num_subrs;
+ decoder.subrs = type1->subrs;
+ decoder.subrs_len = type1->subrs_len;
+
+ decoder.buildchar = face->buildchar;
+ decoder.len_buildchar = face->len_buildchar;
*max_advance = 0;
@@ -191,6 +196,8 @@
/* ignore the error if one occurred - skip to next glyph */
}
+ psaux->t1_decoder_funcs->done( &decoder );
+
return T1_Err_Ok;
}
@@ -212,11 +219,14 @@
FT_Matrix font_matrix;
FT_Vector font_offset;
FT_Data glyph_data;
+ FT_Bool must_finish_decoder = FALSE;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Bool glyph_data_loaded = 0;
#endif
+ FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
+
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
@@ -243,12 +253,17 @@
if ( error )
goto Exit;
+ must_finish_decoder = TRUE;
+
decoder.builder.no_recurse = FT_BOOL(
( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
- decoder.num_subrs = type1->num_subrs;
- decoder.subrs = type1->subrs;
- decoder.subrs_len = type1->subrs_len;
+ decoder.num_subrs = type1->num_subrs;
+ decoder.subrs = type1->subrs;
+ decoder.subrs_len = type1->subrs_len;
+
+ decoder.buildchar = face->buildchar;
+ decoder.len_buildchar = face->len_buildchar;
/* now load the unscaled outline */
error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,
@@ -265,6 +280,8 @@
/* save new glyph tables */
decoder_funcs->done( &decoder );
+ must_finish_decoder = FALSE;
+
/* now, set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax */
@@ -389,6 +406,9 @@
}
#endif
+ if ( must_finish_decoder )
+ decoder_funcs->done( &decoder );
+
return error;
}
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 635e16c..14fba7f 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -2038,6 +2038,22 @@
}
}
+ if ( face->blend )
+ {
+ if ( face->len_buildchar > 0 )
+ {
+ FT_Memory memory = face->root.memory;
+
+
+ if ( FT_NEW_ARRAY( face->buildchar, face->len_buildchar ) )
+ {
+ FT_ERROR(( "T1_Open_Face: cannot allocate BuildCharArray\n" ));
+ face->len_buildchar = 0;
+ goto Exit;
+ }
+ }
+ }
+
#endif /* T1_CONFIG_OPTION_NO_MM_SUPPORT */
/* now, propagate the subrs, charstrings, and glyphnames tables */
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index aa95122..095e7f1 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -201,6 +201,16 @@
#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
/* release multiple masters information */
+ FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
+
+ if ( face->buildchar )
+ {
+ FT_FREE( face->buildchar );
+
+ face->buildchar = NULL;
+ face->len_buildchar = 0;
+ }
+
T1_Done_Blend( face );
face->blend = 0;
#endif