fixed a _nasty_ bug in the CFF driver. Note that there are still escapement problems though..
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
diff --git a/demos/Makefile b/demos/Makefile
index a2b4d9c..e88ddba 100644
--- a/demos/Makefile
+++ b/demos/Makefile
@@ -87,7 +87,7 @@ else
# 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)
diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c
index 6eeec2d..6d92bee 100644
--- 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,32 +1086,60 @@
break;
case t2_op_rlinecurve:
- case t2_op_rcurveline:
{
- FT_Int mod6 = num_args % 6;
-
-
- FT_TRACE4(( op == t2_op_rcurveline ? " rcurveline" :
- " rlinecurve" ));
-
- if ( num_args < 8 || ( mod6 != 0 && mod6 != 2 ) )
+ 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_args / 6 ) * 3 + mod6 / 2 ) )
+
+ if ( start_point( builder, x, y ) ||
+ check_points( builder, num_lines + 3 ) )
goto Memory_Error;
-
+
args = stack;
- if ( op == t2_op_rlinecurve && mod6 )
+
+ /* first, add the line segments */
+ while (num_lines > 0)
{
x += args[0];
y += args[1];
add_point( builder, x, y, 1 );
- args += 2;
- num_args -= 2;
+ 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 num_curves = (num_args-2)/6;
+
- while ( num_args >= 6 )
+ FT_TRACE4(( " rcurveline" ));
+
+ if ( num_args < 8 || (num_args-2) % 6 )
+ goto Stack_Underflow;
+
+ if ( start_point ( builder, x, y ) ||
+ check_points( builder, num_curves*3 + 2 ) )
+ goto Memory_Error;
+
+ args = stack;
+ /* first, add the curves */
+ while (num_curves > 0)
{
x += args[0];
y += args[1];
@@ -1126,16 +1150,13 @@
x += args[4];
y += args[5];
add_point( builder, x, y, 1 );
- args += 6;
- num_args -= 6;
- }
-
- if ( op == t2_op_rcurveline && num_args )
- {
- x += args[0];
- y += args[1];
- add_point( builder, x, y, 1 );
+ args += 6;
+ num_curves--;
}
+ /* 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:
diff --git a/src/cff/t2load.c b/src/cff/t2load.c
index 8758cc2..95015a6 100644
--- 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 */
diff --git a/src/cff/t2parse.c b/src/cff/t2parse.c
index 7692e11..8238a81 100644
--- 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 ) \