forked from minhngoc25a/freetype2
* 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.
This commit is contained in:
parent
ee6e92c28e
commit
efd4e87778
14
ChangeLog
14
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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue