Use FT_SET_ERROR where useful. Other minor code formatting.

This commit is contained in:
Werner Lemberg 2016-12-17 20:47:42 +01:00
parent db17ceb4c0
commit 5d664b6d51
11 changed files with 51 additions and 60 deletions

View File

@ -942,13 +942,14 @@
/* if it works, fine. */ /* if it works, fine. */
error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface ); error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface );
if ( error == 0 ) if ( error )
return error; {
/* let it fall through to normal loader (.ttf, .otf, etc.); */
/* we signal this by returning no error and no FT_Face */
*aface = NULL;
}
/* let it fall through to normal loader (.ttf, .otf, etc.); */ return FT_Err_Ok;
/* we signal this by returning no error and no FT_Face */
*aface = NULL;
return 0;
} }
@ -982,12 +983,13 @@
/* try resourcefork based font: LWFN, FFIL */ /* try resourcefork based font: LWFN, FFIL */
error = FT_New_Face_From_Resource( library, (UInt8 *)pathname, error = FT_New_Face_From_Resource( library, (UInt8 *)pathname,
face_index, aface ); face_index, aface );
if ( error != 0 || *aface != NULL ) if ( error || *aface )
return error; return error;
/* let it fall through to normal loader (.ttf, .otf, etc.) */ /* let it fall through to normal loader (.ttf, .otf, etc.) */
args.flags = FT_OPEN_PATHNAME; args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname; args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface ); return FT_Open_Face( library, &args, face_index, aface );
} }

View File

@ -1400,7 +1400,7 @@
error = FT_Open_Face( library, &args, face_index, aface ); error = FT_Open_Face( library, &args, face_index, aface );
if ( error == FT_Err_Ok ) if ( !error )
(*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM; (*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
else else
#ifdef FT_MACINTOSH #ifdef FT_MACINTOSH
@ -1758,11 +1758,12 @@
aface ); aface );
Exit2: Exit2:
if ( error == FT_ERR( Array_Too_Large ) ) if ( FT_ERR_EQ( error, Array_Too_Large ) )
FT_TRACE2(( " Abort due to too-short buffer to store" FT_TRACE2(( " Abort due to too-short buffer to store"
" all POST fragments\n" )); " all POST fragments\n" ));
else if ( error == FT_ERR( Invalid_Offset ) ) else if ( FT_ERR_EQ( error, Invalid_Offset ) )
FT_TRACE2(( " Abort due to invalid offset in a POST fragment\n" )); FT_TRACE2(( " Abort due to invalid offset in a POST fragment\n" ));
if ( error ) if ( error )
error = FT_ERR( Cannot_Open_Resource ); error = FT_ERR( Cannot_Open_Resource );
FT_FREE( pfb_data ); FT_FREE( pfb_data );

View File

@ -423,7 +423,7 @@ THE SOFTWARE.
else else
bdfface->family_name = NULL; bdfface->family_name = NULL;
if ( ( error = bdf_interpret_style( face ) ) != 0 ) if ( FT_SET_ERROR( bdf_interpret_style( face ) ) )
goto Exit; goto Exit;
/* the number of glyphs (with one slot for the undefined glyph */ /* the number of glyphs (with one slot for the undefined glyph */

View File

@ -2301,7 +2301,7 @@
p->font->comments[p->font->comments_len] = 0; p->font->comments[p->font->comments_len] = 0;
} }
} }
else if ( error == FT_Err_Ok ) else if ( !error )
error = FT_THROW( Invalid_File_Format ); error = FT_THROW( Invalid_File_Format );
*font = p->font; *font = p->font;

View File

@ -44,7 +44,7 @@
cf2_setError( FT_Error* error, cf2_setError( FT_Error* error,
FT_Error value ) FT_Error value )
{ {
if ( error && *error == 0 ) if ( error && !*error )
*error = value; *error = value;
} }

View File

@ -1260,8 +1260,8 @@ THE SOFTWARE.
if ( face->accel.constantWidth ) if ( face->accel.constantWidth )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
if ( ( error = pcf_interpret_style( face ) ) != 0 ) if ( FT_SET_ERROR( pcf_interpret_style( face ) ) )
goto Exit; goto Exit;
prop = pcf_find_property( face, "FAMILY_NAME" ); prop = pcf_find_property( face, "FAMILY_NAME" );
if ( prop && prop->isString ) if ( prop && prop->isString )

View File

@ -347,7 +347,7 @@
size, size,
gindex, gindex,
( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) != 0 ); ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) != 0 );
if ( error == 0 ) if ( !error )
goto Exit; goto Exit;
} }

View File

@ -752,10 +752,8 @@
if ( arg_cnt != 0 ) if ( arg_cnt != 0 )
goto Unexpected_OtherSubr; goto Unexpected_OtherSubr;
if ( ( error = t1_builder_start_point( builder, x, y ) ) if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
!= FT_Err_Ok || FT_SET_ERROR( t1_builder_check_points( builder, 6 ) ) )
( error = t1_builder_check_points( builder, 6 ) )
!= FT_Err_Ok )
goto Fail; goto Fail;
decoder->flex_state = 1; decoder->flex_state = 1;
@ -1200,8 +1198,7 @@
case op_hlineto: case op_hlineto:
FT_TRACE4(( " hlineto" )); FT_TRACE4(( " hlineto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) ) if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) )
!= FT_Err_Ok )
goto Fail; goto Fail;
x += top[0]; x += top[0];
@ -1222,10 +1219,8 @@
case op_hvcurveto: case op_hvcurveto:
FT_TRACE4(( " hvcurveto" )); FT_TRACE4(( " hvcurveto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) ) if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
!= FT_Err_Ok || FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) )
( error = t1_builder_check_points( builder, 3 ) )
!= FT_Err_Ok )
goto Fail; goto Fail;
x += top[0]; x += top[0];
@ -1240,16 +1235,14 @@
case op_rlineto: case op_rlineto:
FT_TRACE4(( " rlineto" )); FT_TRACE4(( " rlineto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) ) if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) )
!= FT_Err_Ok )
goto Fail; goto Fail;
x += top[0]; x += top[0];
y += top[1]; y += top[1];
Add_Line: Add_Line:
if ( ( error = t1_builder_add_point1( builder, x, y ) ) if ( FT_SET_ERROR( t1_builder_add_point1( builder, x, y ) ) )
!= FT_Err_Ok )
goto Fail; goto Fail;
break; break;
@ -1269,10 +1262,8 @@
case op_rrcurveto: case op_rrcurveto:
FT_TRACE4(( " rrcurveto" )); FT_TRACE4(( " rrcurveto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) ) if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
!= FT_Err_Ok || FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) )
( error = t1_builder_check_points( builder, 3 ) )
!= FT_Err_Ok )
goto Fail; goto Fail;
x += top[0]; x += top[0];
@ -1291,10 +1282,8 @@
case op_vhcurveto: case op_vhcurveto:
FT_TRACE4(( " vhcurveto" )); FT_TRACE4(( " vhcurveto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) ) if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
!= FT_Err_Ok || FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) )
( error = t1_builder_check_points( builder, 3 ) )
!= FT_Err_Ok )
goto Fail; goto Fail;
y += top[0]; y += top[0];
@ -1309,8 +1298,7 @@
case op_vlineto: case op_vlineto:
FT_TRACE4(( " vlineto" )); FT_TRACE4(( " vlineto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) ) if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) )
!= FT_Err_Ok )
goto Fail; goto Fail;
y += top[0]; y += top[0];

View File

@ -3756,7 +3756,7 @@
error = clazz->validate( cmap, FT_VALIDATOR( &valid ) ); error = clazz->validate( cmap, FT_VALIDATOR( &valid ) );
} }
if ( valid.validator.error == 0 ) if ( !valid.validator.error )
{ {
FT_CMap ttcmap; FT_CMap ttcmap;

View File

@ -1796,11 +1796,11 @@
/* this call provides additional offsets */ /* this call provides additional offsets */
/* for each component's translation */ /* for each component's translation */
if ( ( error = TT_Vary_Apply_Glyph_Deltas( if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas(
face, face,
glyph_index, glyph_index,
&outline, &outline,
(FT_UInt)outline.n_points ) ) != 0 ) (FT_UInt)outline.n_points ) ) )
goto Exit1; goto Exit1;
subglyph = gloader->current.subglyphs; subglyph = gloader->current.subglyphs;

View File

@ -954,10 +954,10 @@
FT_TRACE2(( "GVAR " )); FT_TRACE2(( "GVAR " ));
if ( ( error = face->goto_table( face, if ( FT_SET_ERROR( face->goto_table( face,
TTAG_gvar, TTAG_gvar,
stream, stream,
&table_len ) ) != 0 ) &table_len ) ) )
{ {
FT_TRACE2(( "is missing\n" )); FT_TRACE2(( "is missing\n" ));
goto Exit; goto Exit;
@ -1322,12 +1322,12 @@
FT_TRACE2(( "FVAR " )); FT_TRACE2(( "FVAR " ));
/* both `fvar' and `gvar' must be present */ /* both `fvar' and `gvar' must be present */
if ( ( error = face->goto_table( face, TTAG_gvar, if ( FT_SET_ERROR( face->goto_table( face, TTAG_gvar,
stream, &table_len ) ) != 0 ) stream, &table_len ) ) )
{ {
/* CFF2 is an alternate to gvar here */ /* CFF2 is an alternate to gvar here */
if ( ( error = face->goto_table( face, TTAG_CFF2, if ( FT_SET_ERROR( face->goto_table( face, TTAG_CFF2,
stream, &table_len ) ) != 0 ) stream, &table_len ) ) )
{ {
FT_TRACE1(( "\n" FT_TRACE1(( "\n"
"TT_Get_MM_Var: `gvar' or `CFF2' table is missing\n" )); "TT_Get_MM_Var: `gvar' or `CFF2' table is missing\n" ));
@ -1335,8 +1335,8 @@
} }
} }
if ( ( error = face->goto_table( face, TTAG_fvar, if ( FT_SET_ERROR( face->goto_table( face, TTAG_fvar,
stream, &table_len ) ) != 0 ) stream, &table_len ) ) )
{ {
FT_TRACE1(( "is missing\n" )); FT_TRACE1(( "is missing\n" ));
goto Exit; goto Exit;
@ -1589,7 +1589,7 @@
if ( face->blend == NULL ) if ( face->blend == NULL )
{ {
if ( ( error = TT_Get_MM_Var( face, NULL ) ) != 0 ) if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
goto Exit; goto Exit;
} }
@ -1624,7 +1624,7 @@
FT_TRACE5(( "\n" )); FT_TRACE5(( "\n" ));
if ( !face->isCFF2 && blend->glyphoffsets == NULL ) if ( !face->isCFF2 && blend->glyphoffsets == NULL )
if ( ( error = ft_var_load_gvar( face ) ) != 0 ) if ( FT_SET_ERROR( ft_var_load_gvar( face ) ) )
goto Exit; goto Exit;
if ( blend->normalizedcoords == NULL ) if ( blend->normalizedcoords == NULL )
@ -1740,7 +1740,7 @@
if ( face->blend == NULL ) if ( face->blend == NULL )
{ {
if ( ( error = TT_Get_MM_Var( face, NULL ) ) != 0 ) if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
return error; return error;
} }
@ -1805,7 +1805,7 @@
if ( face->blend == NULL ) if ( face->blend == NULL )
{ {
if ( ( error = TT_Get_MM_Var( face, NULL ) ) != 0 ) if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
goto Exit; goto Exit;
} }