Index: t2gload.c =================================================================== RCS file: /cvsroot/freetype2/src/cff/t2gload.c,v retrieving revision 1.21 diff -u -r1.21 t2gload.c --- t2gload.c 2000/07/02 00:27:50 1.21 +++ t2gload.c 2000/07/05 01:35:06 @@ -403,14 +403,15 @@ FT_Vector* point = outline->points + outline->n_points; FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points; - - point->x = x >> 16; - point->y = y >> 16; + /* XXXX: Already a 32 bit number occupying low 16 bits. No need to shift down */ + point->x = x; + point->y = y; *control = flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic; - builder->last = *point; } + outline->n_points++; + } @@ -456,27 +457,28 @@ return error; } - - /* if a path was begun, add its first on-curve point */ + /* XXXX: Only add a point if we are truly starting a new path. Avoids duplicate */ + /* points on the path. */ static FT_Error start_point( T2_Builder* builder, FT_Pos x, FT_Pos y ) { + + FT_Error error = 0; + /* test whether we are building a new contour */ if ( !builder->path_begun ) { - FT_Error error; - - builder->path_begun = 1; error = add_contour( builder ); - if ( error ) - return error; + if (!error) + error = add_point1( builder, x, y ); } - return add_point1( builder, x, y ); + return error; + } @@ -597,16 +599,17 @@ v = *ip++; if ( v >= 32 || v == 28 ) { - FT_Int shift = 16; - FT_Long val; - - +#if SIZEOF_INT == 4 + FT_Int val; +#else + FT_Long val; +#endif /* this is an operand, push it on the stack */ if ( v == 28 ) { if ( ip + 1 >= limit ) goto Syntax_Error; - val = (FT_Short)( ( (FT_Int)ip[0] << 8 ) + ip[1] ); + val = (FT_Int)ip[0] << 8 | ip[1] ; ip += 2; } else if ( v < 247 ) @@ -627,22 +630,30 @@ { if ( ip + 3 >= limit ) goto Syntax_Error; +#if SIZEOF_INT == 4 + val = ( (FT_Int)ip[0] << 24 ) | + ( (FT_Int)ip[1] << 16 ) | + ( (FT_Int)ip[2] << 8 ) | + ip[3]; +#else val = ( (FT_Long)ip[0] << 24 ) | ( (FT_Long)ip[1] << 16 ) | ( (FT_Long)ip[2] << 8 ) | ip[3]; +#endif + /* XXXX: Five byte encoded numbers are different in Type 2 charstrings... */ + /* We shift down now and clobber the fractional portion. */ + val >>= 16; ip += 4; - shift = 0; } if ( decoder->top - stack >= T2_MAX_OPERANDS ) goto Stack_Overflow; - val <<= shift; *decoder->top++ = val; #ifdef FT_DEBUG_LEVEL_TRACE if ( !( val & 0xFFFF ) ) - FT_TRACE4(( " %d", (FT_Int)( val >> 16 ) )); + FT_TRACE4(( " %d", (FT_Int)val )); else FT_TRACE4(( " %.2f", val/65536.0 )); #endif @@ -837,8 +848,7 @@ args = stack; if ( num_args & 1 && decoder->read_width ) { - decoder->glyph_width = decoder->nominal_width + - ( stack[0] >> 16 ); + decoder->glyph_width = decoder->nominal_width + stack[0]; num_args--; args++; } @@ -901,7 +911,7 @@ break; case t2_op_hmoveto: - FT_TRACE4(( " vmoveto" )); + FT_TRACE4(( " hmoveto" )); close_contour( builder ); builder->path_begun = 0; @@ -924,7 +934,8 @@ { x += args[0]; y += args[1]; - add_point( builder, x, y, 1 ); + if ( add_point1( builder, x, y ) ) + goto Memory_Error; args += 2; } args = stack; @@ -1312,7 +1323,7 @@ case t2_op_index: { - FT_Int index = args[0] >> 16; + FT_Int index = args[0]; FT_TRACE4(( " index" )); @@ -1328,8 +1339,8 @@ case t2_op_roll: { - FT_Int count = (FT_Int)( args[0] >> 16 ); - FT_Int index = (FT_Int)( args[1] >> 16 ); + FT_Int count = (FT_Int)args[0]; + FT_Int index = (FT_Int)args[1]; FT_TRACE4(( " roll" )); @@ -1383,7 +1394,7 @@ case t2_op_put: { FT_Fixed val = args[0]; - FT_Int index = (FT_Int)( args[1] >> 16 ); + FT_Int index = (FT_Int)args[1]; FT_TRACE4(( " put" )); @@ -1395,7 +1406,7 @@ case t2_op_get: { - FT_Int index = (FT_Int)( args[0] >> 16 ); + FT_Int index = (FT_Int)args[0]; FT_Fixed val = 0; @@ -1470,8 +1481,7 @@ case t2_op_callsubr: { - FT_UInt index = (FT_UInt)( ( args[0] >> 16 ) + - decoder->locals_bias ); + FT_UInt index = (FT_UInt)( args[0] + decoder->locals_bias ); FT_TRACE4(( " callsubr(%d)", index )); @@ -1510,8 +1520,7 @@ case t2_op_callgsubr: { - FT_UInt index = (FT_UInt)( ( args[0] >> 16 ) + - decoder->globals_bias ); + FT_UInt index = (FT_UInt)( args[0] + decoder->globals_bias ); FT_TRACE4(( " callgsubr(%d)", index )); @@ -1789,10 +1798,9 @@ FT_Fixed x_scale = glyph->x_scale; FT_Fixed y_scale = glyph->y_scale; - /* First of all, scale the points */ for ( n = cur->n_points; n > 0; n--, vec++ ) - { + { vec->x = FT_MulFix( vec->x, x_scale ); vec->y = FT_MulFix( vec->y, y_scale ); }