* include/freetype/internal/psaux.h (T1_ParseState): New enumeration. (T1_BuilderRec): Replace `path_begun' with `parse_state'. Remove `error'. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Replace `Memory_Error' with `Fail' and update all users. Don't use `builder->error'. Replace `path_begun' with `parse_state' and check parsing states. * src/psaux/psobjs.c (t1_builder_init, t1_builder_start_point): Replace `path_begun' with `parse_state' and check parsing states.
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
diff --git a/ChangeLog b/ChangeLog
index ed1aad4..4cffb9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2004-05-11 Werner Lemberg <wl@gnu.org>
+
+ * include/freetype/internal/psaux.h (T1_ParseState): New
+ enumeration.
+ (T1_BuilderRec): Replace `path_begun' with `parse_state'.
+ Remove `error'.
+ * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Replace
+ `Memory_Error' with `Fail' and update all users.
+ Don't use `builder->error'.
+ Replace `path_begun' with `parse_state' and check parsing states.
+
+ * src/psaux/psobjs.c (t1_builder_init, t1_builder_start_point):
+ Replace `path_begun' with `parse_state' and check parsing states.
+
2004-05-10 George Williams <gww@silcom.com>
* src/truetype/ttxgvar.c (ft_var_load_avar): Do free arrays in case
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index 8d419be..cf1abf4 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -5,7 +5,7 @@
/* Auxiliary functions and data structures related to PostScript fonts */
/* (specification). */
/* */
-/* Copyright 1996-2001, 2002, 2003 by */
+/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -478,6 +478,17 @@ FT_BEGIN_HEADER
} T1_Builder_FuncsRec;
+ /* an enumeration type to handle charstring parsing states */
+ typedef enum T1_ParseState_
+ {
+ T1_Parse_Start,
+ T1_Parse_Have_Width,
+ T1_Parse_Have_Moveto,
+ T1_Parse_Have_Path
+
+ } T1_ParseState;
+
+
/*************************************************************************/
/* */
/* <Structure> */
@@ -519,15 +530,13 @@ FT_BEGIN_HEADER
/* */
/* bbox :: Unused. */
/* */
- /* path_begun :: A flag which indicates that a new path has begun. */
+ /* parse_state :: An enumeration which controls the charstring */
+ /* parsing state. */
/* */
/* load_points :: If this flag is not set, no points are loaded. */
/* */
/* no_recurse :: Set but not used. */
/* */
- /* error :: An error code that is only used to report memory */
- /* allocation problems. */
- /* */
/* metrics_only :: A boolean indicating that we only want to compute */
/* the metrics of a given glyph, not load all of its */
/* points. */
@@ -555,12 +564,11 @@ FT_BEGIN_HEADER
FT_Vector advance;
FT_BBox bbox; /* bounding box */
- FT_Bool path_begun;
+ T1_ParseState parse_state;
FT_Bool load_points;
FT_Bool no_recurse;
FT_Bool shift;
- FT_Error error; /* only used for memory errors */
FT_Bool metrics_only;
void* hints_funcs; /* hinter-specific */
diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c
index 0308f71..94a0706 100644
--- a/src/base/ftgloadr.c
+++ b/src/base/ftgloadr.c
@@ -182,14 +182,14 @@
}
- /* Ensure that we can add `n_points' and `n_contours' to our glyph. this */
- /* function reallocates its outline tables if necessary. Note that it */
- /* DOESN'T change the number of points within the loader! */
+ /* Ensure that we can add `n_points' and `n_contours' to our glyph. */
+ /* This function reallocates its outline tables if necessary. Note that */
+ /* it DOESN'T change the number of points within the loader! */
/* */
FT_BASE_DEF( FT_Error )
FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader,
- FT_UInt n_points,
- FT_UInt n_contours )
+ FT_UInt n_points,
+ FT_UInt n_contours )
{
FT_Memory memory = loader->memory;
FT_Error error = FT_Err_Ok;
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index c1339d8..3df1cf7 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -1344,7 +1344,7 @@
case cff_op_vvcurveto:
FT_TRACE4(( " vvcurveto" ));
- if ( cff_builder_start_point ( builder, x, y ) )
+ if ( cff_builder_start_point( builder, x, y ) )
goto Memory_Error;
args = stack;
@@ -1378,7 +1378,7 @@
case cff_op_hhcurveto:
FT_TRACE4(( " hhcurveto" ));
- if ( cff_builder_start_point ( builder, x, y ) )
+ if ( cff_builder_start_point( builder, x, y ) )
goto Memory_Error;
args = stack;
@@ -1418,7 +1418,7 @@
FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto"
: " hvcurveto" ));
- if ( cff_builder_start_point ( builder, x, y ) )
+ if ( cff_builder_start_point( builder, x, y ) )
goto Memory_Error;
args = stack;
@@ -1608,7 +1608,7 @@
/* adding six more points; 4 control points, 2 on-curve points */
if ( cff_builder_start_point( builder, x, y ) ||
- check_points ( builder, 6 ) )
+ check_points( builder, 6 ) )
goto Memory_Error;
/* record the starting point's y-position for later use */
@@ -1661,7 +1661,7 @@
/* adding six more points; 4 control points, 2 on-curve points */
if ( cff_builder_start_point( builder, x, y ) ||
check_points( builder, 6 ) )
- goto Memory_Error;
+ goto Memory_Error;
/* record the starting point's x, y postion for later use */
start_x = x;
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index f37cd35..d02986c 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -1543,7 +1543,7 @@
FT_GlyphSlot glyph,
FT_Bool hinting )
{
- builder->path_begun = 0;
+ builder->parse_state = T1_Parse_Start;
builder->load_points = 1;
builder->face = face;
@@ -1700,17 +1700,21 @@
FT_Pos x,
FT_Pos y )
{
- FT_Error error = 0;
+ FT_Error error = PSaux_Err_Invalid_File_Format;
/* test whether we are building a new contour */
- if ( !builder->path_begun )
+
+ if ( builder->parse_state == T1_Parse_Have_Path )
+ error = PSaux_Err_Ok;
+ else if ( builder->parse_state == T1_Parse_Have_Moveto )
{
- builder->path_begun = 1;
+ builder->parse_state = T1_Parse_Have_Path;
error = t1_builder_add_contour( builder );
if ( !error )
error = t1_builder_add_point1( builder, x, y );
}
+
return error;
}
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index db1911e..c2adf48 100644
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -340,7 +340,7 @@
decoder->zone = decoder->zones;
zone = decoder->zones;
- builder->path_begun = 0;
+ builder->parse_state = T1_Parse_Start;
hinter = (T1_Hints_Funcs)builder->hints_funcs;
@@ -556,7 +556,7 @@
decoder->num_flex_vectors = 0;
if ( start_point( builder, x, y ) ||
check_points( builder, 6 ) )
- goto Memory_Error;
+ goto Fail;
break;
case 2: /* add flex vectors */
@@ -747,6 +747,8 @@
case op_hsbw:
FT_TRACE4(( " hsbw" ));
+ builder->parse_state = T1_Parse_Have_Width;
+
builder->left_bearing.x += top[0];
builder->advance.x = top[1];
builder->advance.y = 0;
@@ -772,6 +774,8 @@
case op_sbw:
FT_TRACE4(( " sbw" ));
+ builder->parse_state = T1_Parse_Have_Width;
+
builder->left_bearing.x += top[0];
builder->left_bearing.y += top[1];
builder->advance.x = top[2];
@@ -792,14 +796,16 @@
FT_TRACE4(( " closepath" ));
close_contour( builder );
- builder->path_begun = 0;
+ if ( builder->parse_state != T1_Parse_Have_Path )
+ goto Syntax_Error;
+ builder->parse_state = T1_Parse_Have_Width;
break;
case op_hlineto:
FT_TRACE4(( " hlineto" ));
if ( start_point( builder, x, y ) )
- goto Memory_Error;
+ goto Fail;
x += top[0];
goto Add_Line;
@@ -809,7 +815,11 @@
x += top[0];
if ( !decoder->flex_state )
- builder->path_begun = 0;
+ {
+ if ( builder->parse_state == T1_Parse_Start )
+ goto Syntax_Error;
+ builder->parse_state = T1_Parse_Have_Moveto;
+ }
break;
case op_hvcurveto:
@@ -817,7 +827,7 @@
if ( start_point( builder, x, y ) ||
check_points( builder, 3 ) )
- goto Memory_Error;
+ goto Fail;
x += top[0];
add_point( builder, x, y, 0 );
@@ -832,14 +842,14 @@
FT_TRACE4(( " rlineto" ));
if ( start_point( builder, x, y ) )
- goto Memory_Error;
+ goto Fail;
x += top[0];
y += top[1];
Add_Line:
if ( add_point1( builder, x, y ) )
- goto Memory_Error;
+ goto Fail;
break;
case op_rmoveto:
@@ -848,7 +858,11 @@
x += top[0];
y += top[1];
if ( !decoder->flex_state )
- builder->path_begun = 0;
+ {
+ if ( builder->parse_state == T1_Parse_Start )
+ goto Syntax_Error;
+ builder->parse_state = T1_Parse_Have_Moveto;
+ }
break;
case op_rrcurveto:
@@ -856,7 +870,7 @@
if ( start_point( builder, x, y ) ||
check_points( builder, 3 ) )
- goto Memory_Error;
+ goto Fail;
x += top[0];
y += top[1];
@@ -876,7 +890,7 @@
if ( start_point( builder, x, y ) ||
check_points( builder, 3 ) )
- goto Memory_Error;
+ goto Fail;
y += top[0];
add_point( builder, x, y, 0 );
@@ -891,7 +905,7 @@
FT_TRACE4(( " vlineto" ));
if ( start_point( builder, x, y ) )
- goto Memory_Error;
+ goto Fail;
y += top[0];
goto Add_Line;
@@ -901,7 +915,11 @@
y += top[0];
if ( !decoder->flex_state )
- builder->path_begun = 0;
+ {
+ if ( builder->parse_state == T1_Parse_Start )
+ goto Syntax_Error;
+ builder->parse_state = T1_Parse_Have_Moveto;
+ }
break;
case op_div:
@@ -1072,6 +1090,7 @@
FT_TRACE4(( "..end..\n\n" ));
+ Fail:
return error;
Syntax_Error:
@@ -1079,9 +1098,6 @@
Stack_Underflow:
return PSaux_Err_Stack_Underflow;
-
- Memory_Error:
- return builder->error;
}
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 98f8194..f45a83b 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -60,7 +60,7 @@
{
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font type1 = &face->type1;
- FT_Error error = 0;
+ FT_Error error = T1_Err_Ok;
decoder->font_matrix = type1->font_matrix;