ref: 075cdf12888d239ac2a476bc4f35e517a798659b
parent: 98c2fde0b37d108adfe1af71c15d7b87177627ae
author: David Turner <[email protected]>
date: Wed Jun 28 01:35:58 EDT 2000
fixed a _nasty_ bug in the CFF driver. Note that there are still escapement problems though..
--- a/demos/Makefile
+++ b/demos/Makefile
@@ -87,7 +87,7 @@
# with the program by default on Unix, we thus add it whenever appropriate
#
ifeq ($(PLATFORM),unix)
- LINK += -lm
+ LINK += -lm -lefence
endif
COMMON_LINK = $(LINK) $(COMMON_OBJ)
--- a/src/cff/t2gload.c
+++ b/src/cff/t2gload.c
@@ -363,10 +363,6 @@
if (cff->num_subfonts >= 1)
{
FT_Byte fd_index = CFF_Get_FD( &cff->fd_select, glyph_index );
- if (fd_index >= cff->num_subfonts)
- {
- FT_ERROR(( "INVALID FD INDEX = %d >= %d\n", fd_index, cff->num_subfonts ));
- }
sub = cff->subfonts[fd_index];
}
@@ -1090,35 +1086,63 @@
break;
case t2_op_rlinecurve:
+ {
+ FT_Int num_lines = (num_args-6)/2;
+ FT_TRACE4(( " rlinecurve" ));
+
+ if ( num_args < 8 || (num_args-6) & 1)
+ goto Stack_Underflow;
+
+ if ( start_point( builder, x, y ) ||
+ check_points( builder, num_lines + 3 ) )
+ goto Memory_Error;
+
+ args = stack;
+
+ /* first, add the line segments */
+ while (num_lines > 0)
+ {
+ x += args[0];
+ y += args[1];
+ add_point( builder, x, y, 1 );
+ args += 2;
+ num_lines--;
+ }
+
+ /* then, the curve */
+ x += args[0];
+ y += args[1];
+ add_point( builder, x, y, 0 );
+ x += args[2];
+ y += args[3];
+ add_point( builder, x, y, 0 );
+ x += args[4];
+ y += args[5];
+ add_point( builder, x, y, 1 );
+ args = stack;
+ }
+ break;
+
case t2_op_rcurveline:
{
- FT_Int mod6 = num_args % 6;
+ FT_Int num_curves = (num_args-2)/6;
- FT_TRACE4(( op == t2_op_rcurveline ? " rcurveline" :
- " rlinecurve" ));
+ FT_TRACE4(( " rcurveline" ));
- if ( num_args < 8 || ( mod6 != 0 && mod6 != 2 ) )
+ if ( num_args < 8 || (num_args-2) % 6 )
goto Stack_Underflow;
- if ( start_point ( builder, x, y ) ||
- check_points( builder, ( num_args / 6 ) * 3 + mod6 / 2 ) )
+ if ( start_point ( builder, x, y ) ||
+ check_points( builder, num_curves*3 + 2 ) )
goto Memory_Error;
args = stack;
- if ( op == t2_op_rlinecurve && mod6 )
+ /* first, add the curves */
+ while (num_curves > 0)
{
x += args[0];
y += args[1];
- add_point( builder, x, y, 1 );
- args += 2;
- num_args -= 2;
- }
-
- while ( num_args >= 6 )
- {
- x += args[0];
- y += args[1];
add_point( builder, x, y, 0 );
x += args[2];
y += args[3];
@@ -1126,16 +1150,13 @@
x += args[4];
y += args[5];
add_point( builder, x, y, 1 );
- args += 6;
- num_args -= 6;
+ args += 6;
+ num_curves--;
}
-
- if ( op == t2_op_rcurveline && num_args )
- {
- x += args[0];
- y += args[1];
- add_point( builder, x, y, 1 );
- }
+ /* then the final line */
+ x += args[0];
+ y += args[1];
+ add_point( builder, x, y, 1 );
args = stack;
}
break;
@@ -1528,12 +1549,15 @@
return error;
Syntax_Error:
+ FT_TRACE4(( "** Syntax Error **" ));
return T2_Err_Invalid_File_Format;
Stack_Underflow:
+ FT_TRACE4(( "** Stack underflow **" ));
return T2_Err_Too_Few_Arguments;
Stack_Overflow:
+ FT_TRACE4(( "** Stack overflow**" ));
return T2_Err_Stack_Overflow;
Memory_Error:
--- a/src/cff/t2load.c
+++ b/src/cff/t2load.c
@@ -354,7 +354,8 @@
if ( FILE_Seek(offset) || READ_Byte(format) )
goto Exit;
- select->format = format;
+ select->format = format;
+ select->cache_count = 0; /* clear cache */
switch (format)
{
case 0: /* format 0, that's simple */
--- a/src/cff/t2parse.c
+++ b/src/cff/t2parse.c
@@ -404,7 +404,7 @@
t2_kind_delta, \
code | T2CODE, \
(FT_UInt)(char*)&T2_REF( T2TYPE, name ), \
- sizeof( T2_REF( T2TYPE, name ) ), \
+ sizeof( T2_REF( T2TYPE, name )[0] ), \
0, \
max, \
(FT_UInt)(char*)&T2_REF( T2TYPE, num_ ## name ) \