diff --git a/ChangeLog b/ChangeLog index a43f198e8..236e9a9c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-03-14 Werner Lemberg + + */*: Use FT_ERR_EQ, FT_ERR_NEQ, and FT_ERR where appropriate. + + FT_Err_XXX and friends are no longer directly used in the source + code. + 2013-03-14 Werner Lemberg New error management macros. diff --git a/src/base/ftadvanc.c b/src/base/ftadvanc.c index 880830a0a..52078478d 100644 --- a/src/base/ftadvanc.c +++ b/src/base/ftadvanc.c @@ -93,7 +93,7 @@ if ( !error ) return _ft_face_scale_advances( face, padvance, 1, flags ); - if ( error != FT_ERROR_BASE( FT_Err_Unimplemented_Feature ) ) + if ( FT_ERR_NEQ( error, Unimplemented_Feature ) ) return error; } @@ -133,7 +133,7 @@ if ( !error ) return _ft_face_scale_advances( face, padvances, count, flags ); - if ( error != FT_ERROR_BASE( FT_Err_Unimplemented_Feature ) ) + if ( FT_ERR_NEQ( error, Unimplemented_Feature ) ) return error; } diff --git a/src/base/ftbdf.c b/src/base/ftbdf.c index d29adf09d..5755f8558 100644 --- a/src/base/ftbdf.c +++ b/src/base/ftbdf.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing BDF-specific strings (body). */ /* */ -/* Copyright 2002, 2003, 2004 by */ +/* Copyright 2002-2004, 2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -33,7 +33,7 @@ const char* registry = NULL; - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( face ) { @@ -66,7 +66,7 @@ FT_Error error; - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); aproperty->type = BDF_PROPERTY_TYPE_NONE; diff --git a/src/base/ftcid.c b/src/base/ftcid.c index 733aae147..741879d92 100644 --- a/src/base/ftcid.c +++ b/src/base/ftcid.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing CID font information. */ /* */ -/* Copyright 2007, 2009 by Derek Clegg, Michael Toftdal. */ +/* Copyright 2007, 2009, 2013 by Derek Clegg, Michael Toftdal. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ @@ -35,7 +35,7 @@ FT_Int s = 0; - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( face ) { @@ -65,7 +65,7 @@ FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face, FT_Bool *is_cid ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); FT_Bool ic = 0; @@ -92,7 +92,7 @@ FT_UInt glyph_index, FT_UInt *cid ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); FT_UInt c = 0; diff --git a/src/base/ftmac.c b/src/base/ftmac.c index ce0af549c..456b1a5b4 100644 --- a/src/base/ftmac.c +++ b/src/base/ftmac.c @@ -228,7 +228,7 @@ err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index ); - if ( FT_Err_Ok != err ) + if ( err ) return err; if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) ) @@ -257,7 +257,7 @@ err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index ); - if ( FT_Err_Ok != err ) + if ( err ) return err; if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL, @@ -556,7 +556,7 @@ { err = lookup_lwfn_by_fond( pathname, lwfn_file_name, buff, sizeof ( buff ) ); - if ( FT_Err_Ok == err ) + if ( !err ) have_lwfn = 1; } @@ -796,7 +796,7 @@ FT_Long face_index, FT_Face* aface ) { - FT_Error error = FT_Err_Cannot_Open_Resource; + FT_Error error = FT_ERR( Cannot_Open_Resource ); ResFileRefNum res_ref; ResourceIndex res_index; Handle fond; @@ -827,7 +827,7 @@ } CloseResFile( res_ref ); - if ( FT_Err_Ok == error && NULL != aface && NULL != *aface ) + if ( !error && aface && *aface ) (*aface)->num_faces = num_faces_in_res; return error; } @@ -882,7 +882,7 @@ error = lookup_lwfn_by_fond( path_fond, lwfn_file_name, path_lwfn, sizeof ( path_lwfn ) ); - if ( FT_Err_Ok == error ) + if ( !error ) have_lwfn = 1; } } @@ -896,7 +896,7 @@ error = FT_THROW( Unknown_File_Format ); found_no_lwfn_file: - if ( have_sfnt && FT_Err_Ok != error ) + if ( have_sfnt && error ) error = FT_New_Face_From_SFNT( library, sfnt_id, face_index, diff --git a/src/base/ftmm.c b/src/base/ftmm.c index 62db590ef..18ff879bf 100644 --- a/src/base/ftmm.c +++ b/src/base/ftmm.c @@ -46,7 +46,7 @@ if ( !face ) return FT_THROW( Invalid_Face_Handle ); - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( FT_HAS_MULTIPLE_MASTERS( face ) ) { @@ -75,7 +75,7 @@ error = ft_face_get_mm_service( face, &service ); if ( !error ) { - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( service->get_mm ) error = service->get_mm( face, amaster ); } @@ -97,7 +97,7 @@ error = ft_face_get_mm_service( face, &service ); if ( !error ) { - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( service->get_mm_var ) error = service->get_mm_var( face, amaster ); } @@ -120,7 +120,7 @@ error = ft_face_get_mm_service( face, &service ); if ( !error ) { - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( service->set_mm_design ) error = service->set_mm_design( face, num_coords, coords ); } @@ -143,7 +143,7 @@ error = ft_face_get_mm_service( face, &service ); if ( !error ) { - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( service->set_var_design ) error = service->set_var_design( face, num_coords, coords ); } @@ -166,7 +166,7 @@ error = ft_face_get_mm_service( face, &service ); if ( !error ) { - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( service->set_mm_blend ) error = service->set_mm_blend( face, num_coords, coords ); } @@ -192,7 +192,7 @@ error = ft_face_get_mm_service( face, &service ); if ( !error ) { - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( service->set_mm_blend ) error = service->set_mm_blend( face, num_coords, coords ); } diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 167b11054..5ed39f1b2 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1166,7 +1166,7 @@ /* is returned. */ /* no error should happen, but we want to play safe */ - if ( error2 && error2 != FT_Err_Invalid_CharMap_Handle ) + if ( error2 && FT_ERR_NEQ( error2, Invalid_CharMap_Handle ) ) { error = error2; goto Fail; @@ -1513,7 +1513,7 @@ FT_Error error1; - if ( error == FT_Err_Unknown_File_Format ) + if ( FT_ERR_EQ( error, Unknown_File_Format ) ) { error1 = FT_Stream_Seek( stream, pos ); if ( error1 ) @@ -1541,7 +1541,7 @@ FT_Long face_index, FT_Face *aface ) { - FT_Error error = FT_Err_Cannot_Open_Resource; + FT_Error error = FT_ERR( Cannot_Open_Resource ); FT_Memory memory = library->memory; FT_Byte* pfb_data = NULL; int i, type, flags; @@ -1634,7 +1634,7 @@ pfb_data[pfb_pos++] = 0; } - error = FT_Err_Cannot_Open_Resource; + error = FT_ERR( Cannot_Open_Resource ); if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) goto Exit2; @@ -1863,7 +1863,7 @@ #define FT_COMPONENT trace_raccess FT_Memory memory = library->memory; - FT_Error error = FT_Err_Unknown_File_Format; + FT_Error error = FT_ERR( Unknown_File_Format ); int i; char * file_names[FT_RACCESS_N_RULES]; @@ -1902,7 +1902,7 @@ i, args2.pathname, offsets[i] )); error = FT_Stream_New( library, &args2, &stream2 ); - if ( is_darwin_vfs && error == FT_Err_Cannot_Open_Stream ) + if ( is_darwin_vfs && FT_ERR_EQ( error, Cannot_Open_Stream ) ) vfs_rfork_has_no_font = TRUE; if ( error ) @@ -1931,7 +1931,7 @@ /* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */ if ( error ) - error = FT_Err_Unknown_File_Format; + error = FT_ERR( Unknown_File_Format ); return error; @@ -1960,7 +1960,7 @@ error = IsMacBinary( library, stream, face_index, aface ); - if ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format ) + if ( FT_ERR_EQ( error, Unknown_File_Format ) ) { #undef FT_COMPONENT @@ -1977,9 +1977,9 @@ } - if ( ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format || - FT_ERROR_BASE( error ) == FT_Err_Invalid_Stream_Operation ) && - ( args->flags & FT_OPEN_PATHNAME ) ) + if ( ( FT_ERR_EQ( error, Unknown_File_Format ) || + FT_ERR_EQ( error, Invalid_Stream_Operation ) ) && + ( args->flags & FT_OPEN_PATHNAME ) ) error = load_face_in_embedded_rfork( library, stream, face_index, aface, args ); return error; @@ -2056,7 +2056,7 @@ } else { - error = FT_Err_Missing_Module; + error = FT_ERR( Missing_Module ); /* check each font driver for an appropriate format */ cur = library->modules; @@ -2086,7 +2086,7 @@ #ifdef FT_CONFIG_OPTION_MAC_FONTS if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 && - FT_ERROR_BASE( error ) == FT_Err_Table_Missing ) + FT_ERR_EQ( error, Table_Missing ) ) { /* TrueType but essential tables are missing */ if ( FT_Stream_Seek( stream, 0 ) ) @@ -2106,7 +2106,7 @@ } #endif - if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format ) + if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) goto Fail3; } } @@ -2115,9 +2115,9 @@ /* If we are on the mac, and we get an */ /* FT_Err_Invalid_Stream_Operation it may be because we have an */ /* empty data fork, so we need to check the resource fork. */ - if ( FT_ERROR_BASE( error ) != FT_Err_Cannot_Open_Stream && - FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format && - FT_ERROR_BASE( error ) != FT_Err_Invalid_Stream_Operation ) + if ( FT_ERR_NEQ( error, Cannot_Open_Stream ) && + FT_ERR_NEQ( error, Unknown_File_Format ) && + FT_ERR_NEQ( error, Invalid_Stream_Operation ) ) goto Fail2; #if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS ) @@ -2133,7 +2133,7 @@ return error; } - if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format ) + if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) goto Fail2; #endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */ @@ -2299,7 +2299,7 @@ /* we implement FT_Attach_Stream in each driver through the */ /* `attach_file' interface */ - error = FT_Err_Unimplemented_Feature; + error = FT_ERR( Unimplemented_Feature ); clazz = driver->clazz; if ( clazz->attach_file ) error = clazz->attach_file( face, stream ); @@ -2336,7 +2336,7 @@ FT_ListNode node; - error = FT_Err_Invalid_Face_Handle; + error = FT_ERR( Invalid_Face_Handle ); if ( face && face->driver ) { face->internal->refcount--; @@ -3580,7 +3580,7 @@ FT_Pointer buffer, FT_UInt buffer_max ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); /* clean up buffer */ @@ -4021,12 +4021,12 @@ else renderer = FT_Lookup_Renderer( library, slot->format, &node ); - error = FT_Err_Unimplemented_Feature; + error = FT_ERR( Unimplemented_Feature ); while ( renderer ) { error = renderer->render( renderer, slot, render_mode, NULL ); - if ( !error || - FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph ) + if ( !error || + FT_ERR_NEQ( error, Cannot_Render_Glyph ) ) break; /* FT_Err_Cannot_Render_Glyph is returned if the render mode */ @@ -4839,7 +4839,7 @@ FT_Int *p_arg2, FT_Matrix *p_transform ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); if ( glyph && diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c index 826a7e2ea..54ca5cdcf 100644 --- a/src/base/ftoutln.c +++ b/src/base/ftoutln.c @@ -620,11 +620,11 @@ params->source = (void*)outline; - error = FT_Err_Cannot_Render_Glyph; + error = FT_ERR( Cannot_Render_Glyph ); while ( renderer ) { error = renderer->raster_render( renderer->raster, params ); - if ( !error || FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph ) + if ( !error || FT_ERR_NEQ( error, Cannot_Render_Glyph ) ) break; /* FT_Err_Cannot_Render_Glyph is returned if the render mode */ diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c index 8114531b0..a74948a38 100644 --- a/src/base/ftrfork.c +++ b/src/base/ftrfork.c @@ -838,7 +838,7 @@ { new_names[i] = NULL; offsets[i] = 0; - errors[i] = FT_Err_Unimplemented_Feature; + errors[i] = FT_ERR( Unimplemented_Feature ); } } diff --git a/src/base/ftsnames.c b/src/base/ftsnames.c index 3447888ca..260e91c14 100644 --- a/src/base/ftsnames.c +++ b/src/base/ftsnames.c @@ -44,7 +44,7 @@ FT_UInt idx, FT_SfntName *aname ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); if ( aname && face && FT_IS_SFNT( face ) ) diff --git a/src/base/ftstroke.c b/src/base/ftstroke.c index 1849cb469..ee61ceca0 100644 --- a/src/base/ftstroke.c +++ b/src/base/ftstroke.c @@ -2258,7 +2258,7 @@ FT_Stroker stroker, FT_Bool destroy ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); FT_Glyph glyph = NULL; FT_Library library = stroker->library; @@ -2334,7 +2334,7 @@ FT_Bool inside, FT_Bool destroy ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); FT_Glyph glyph = NULL; FT_Library library = stroker->library; diff --git a/src/base/fttype1.c b/src/base/fttype1.c index 885dba598..c1f9931db 100644 --- a/src/base/fttype1.c +++ b/src/base/fttype1.c @@ -28,7 +28,7 @@ FT_Get_PS_Font_Info( FT_Face face, PS_FontInfoRec* afont_info ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); if ( face ) @@ -73,7 +73,7 @@ FT_Get_PS_Font_Private( FT_Face face, PS_PrivateRec* afont_private ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); if ( face ) diff --git a/src/base/ftwinfnt.c b/src/base/ftwinfnt.c index bc2e90e1f..463ae761d 100644 --- a/src/base/ftwinfnt.c +++ b/src/base/ftwinfnt.c @@ -32,7 +32,7 @@ FT_Error error; - error = FT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( face != NULL ) { diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c index 2f99436c5..134e1ebe9 100644 --- a/src/bdf/bdfdrivr.c +++ b/src/bdf/bdfdrivr.c @@ -365,7 +365,7 @@ THE SOFTWARE. options.font_spacing = BDF_PROPORTIONAL; error = bdf_load_font( stream, memory, &options, &font ); - if ( error == BDF_Err_Missing_Startfont_Field ) + if ( FT_ERR_EQ( error, Missing_Startfont_Field ) ) { FT_TRACE2(( " not a BDF file\n" )); goto Fail; @@ -619,7 +619,7 @@ THE SOFTWARE. FT_Face face = size->face; FT_Bitmap_Size* bsize = face->available_sizes; bdf_font_t* bdffont = ( (BDF_Face)face )->bdffont; - FT_Error error = BDF_Err_Invalid_Pixel_Size; + FT_Error error = FT_ERR( Invalid_Pixel_Size ); FT_Long height; diff --git a/src/cache/ftccache.h b/src/cache/ftccache.h index 54a197857..86f2fca58 100644 --- a/src/cache/ftccache.h +++ b/src/cache/ftccache.h @@ -327,7 +327,7 @@ FT_BEGIN_HEADER #define FTC_CACHE_TRYLOOP_END( list_changed ) \ - if ( !error || error != FTC_Err_Out_Of_Memory ) \ + if ( !error || FT_ERR_NEQ( error, Out_Of_Memory ) ) \ break; \ \ _try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \ diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c index 96183a706..b1c6bd596 100644 --- a/src/cache/ftcmanag.c +++ b/src/cache/ftcmanag.c @@ -575,7 +575,7 @@ FTC_CacheClass clazz, FTC_Cache *acache ) { - FT_Error error = FTC_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); FTC_Cache cache = NULL; diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c index f2c1db77a..6df1c1993 100644 --- a/src/cache/ftcsbits.c +++ b/src/cache/ftcsbits.c @@ -189,7 +189,7 @@ /* we mark unloaded glyphs with `sbit.buffer == 0' */ /* and `width == 255', `height == 0' */ /* */ - if ( error && error != FTC_Err_Out_Of_Memory ) + if ( error && FT_ERR_NEQ( error, Out_Of_Memory ) ) { BadGlyph: sbit->width = 255; diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index 12699b49a..6a65cc8cf 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -959,8 +959,8 @@ error = FT_CMap_New( &CFF_CMAP_UNICODE_CLASS_REC_GET, NULL, &cmaprec, NULL ); - if ( error && - FT_ERROR_BASE( error ) != FT_Err_No_Unicode_Glyph_Name ) + if ( error && + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) goto Exit; error = FT_Err_Ok; diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c index a98f5d1e6..319e61bc0 100644 --- a/src/cff/cffparse.c +++ b/src/cff/cffparse.c @@ -515,7 +515,7 @@ FT_Vector* offset = &dict->font_offset; FT_ULong* upm = &dict->units_per_em; FT_Byte** data = parser->stack; - FT_Error error = CFF_Err_Stack_Underflow; + FT_Error error = FT_ERR( Stack_Underflow ); if ( parser->top >= parser->stack + 6 ) @@ -588,7 +588,7 @@ FT_Error error; - error = CFF_Err_Stack_Underflow; + error = FT_ERR( Stack_Underflow ); if ( parser->top >= parser->stack + 4 ) { @@ -617,7 +617,7 @@ FT_Error error; - error = CFF_Err_Stack_Underflow; + error = FT_ERR( Stack_Underflow ); if ( parser->top >= parser->stack + 2 ) { @@ -641,7 +641,7 @@ FT_Error error; - error = CFF_Err_Stack_Underflow; + error = FT_ERR( Stack_Underflow ); if ( parser->top >= parser->stack + 3 ) { diff --git a/src/gxvalid/gxvmod.c b/src/gxvalid/gxvmod.c index 4c8da3a1d..58a82d0b3 100644 --- a/src/gxvalid/gxvmod.c +++ b/src/gxvalid/gxvmod.c @@ -58,7 +58,7 @@ error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len ); - if ( FT_ERROR_BASE( error ) == FT_Err_Table_Missing ) + if ( FT_ERR_EQ( error, Table_Missing ) ) return FT_Err_Ok; if ( error ) goto Exit; diff --git a/src/otvalid/otvmod.c b/src/otvalid/otvmod.c index da42f6068..37c6e869d 100644 --- a/src/otvalid/otvmod.c +++ b/src/otvalid/otvmod.c @@ -49,7 +49,7 @@ error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len ); - if ( FT_ERROR_BASE( error ) == FT_Err_Table_Missing ) + if ( FT_ERR_EQ( error, Table_Missing ) ) return FT_Err_Ok; if ( error ) goto Exit; diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c index badf8903d..2d8f8af9a 100644 --- a/src/pcf/pcfdrivr.c +++ b/src/pcf/pcfdrivr.c @@ -289,7 +289,7 @@ THE SOFTWARE. /* this didn't work, try gzip support! */ error2 = FT_Stream_OpenGzip( &face->comp_stream, stream ); - if ( FT_ERROR_BASE( error2 ) == FT_Err_Unimplemented_Feature ) + if ( FT_ERR_EQ( error2, Unimplemented_Feature ) ) goto Fail; error = error2; @@ -304,7 +304,7 @@ THE SOFTWARE. /* this didn't work, try LZW support! */ error3 = FT_Stream_OpenLZW( &face->comp_stream, stream ); - if ( FT_ERROR_BASE( error3 ) == FT_Err_Unimplemented_Feature ) + if ( FT_ERR_EQ( error3, Unimplemented_Feature ) ) goto Fail; error = error3; @@ -319,7 +319,7 @@ THE SOFTWARE. /* this didn't work, try Bzip2 support! */ error4 = FT_Stream_OpenBzip2( &face->comp_stream, stream ); - if ( FT_ERROR_BASE( error4 ) == FT_Err_Unimplemented_Feature ) + if ( FT_ERR_EQ( error4, Unimplemented_Feature ) ) goto Fail; error = error4; @@ -434,7 +434,7 @@ THE SOFTWARE. { PCF_Face face = (PCF_Face)size->face; FT_Bitmap_Size* bsize = size->face->available_sizes; - FT_Error error = PCF_Err_Invalid_Pixel_Size; + FT_Error error = FT_ERR( Invalid_Pixel_Size ); FT_Long height; diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c index 3ec8951ce..4b822f798 100644 --- a/src/pcf/pcfread.c +++ b/src/pcf/pcfread.c @@ -294,7 +294,7 @@ THE SOFTWARE. FT_ULong *aformat, FT_ULong *asize ) { - FT_Error error = PCF_Err_Invalid_File_Format; + FT_Error error = FT_ERR( Invalid_File_Format ); FT_ULong i; diff --git a/src/pfr/pfrdrivr.c b/src/pfr/pfrdrivr.c index eec49e727..d0473a41b 100644 --- a/src/pfr/pfrdrivr.c +++ b/src/pfr/pfrdrivr.c @@ -66,7 +66,7 @@ FT_Pos *anadvance ) { PFR_Face face = (PFR_Face)pfrface; - FT_Error error = PFR_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); *anadvance = 0; diff --git a/src/psaux/afmparse.c b/src/psaux/afmparse.c index 4533dd92d..abec50313 100644 --- a/src/psaux/afmparse.c +++ b/src/psaux/afmparse.c @@ -846,7 +846,7 @@ { FT_Memory memory = parser->memory; AFM_FontInfo fi = parser->FontInfo; - FT_Error error = PSaux_Err_Syntax_Error; + FT_Error error = FT_ERR( Syntax_Error ); char* key; FT_Offset len; FT_Int metrics_sets = 0; diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c index 87f460d83..12fc3269a 100644 --- a/src/psaux/psobjs.c +++ b/src/psaux/psobjs.c @@ -341,7 +341,7 @@ { FT_Byte* cur = *acur; FT_Int embed = 0; - FT_Error error = PSaux_Err_Invalid_File_Format; + FT_Error error = FT_ERR( Invalid_File_Format ); unsigned int i; @@ -1315,7 +1315,7 @@ T1_MAX_TABLE_ELEMENTS, &num_elements ); if ( num_elements < 0 ) { - error = PSaux_Err_Ignore; + error = FT_ERR( Ignore ); goto Exit; } if ( (FT_UInt)num_elements > field->array_max ) @@ -1676,7 +1676,7 @@ FT_Pos x, FT_Pos y ) { - FT_Error error = PSaux_Err_Invalid_File_Format; + FT_Error error = FT_ERR( Invalid_File_Format ); /* test whether we are building a new contour */ diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index a2aac0663..8fa4fc9fc 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -503,35 +503,35 @@ } -#define LOAD_( x ) \ - do { \ - FT_TRACE2(( "`" #x "' " )); \ - FT_TRACE3(( "-->\n" )); \ - \ - error = sfnt->load_ ## x( face, stream ); \ - \ - FT_TRACE2(( "%s\n", ( !error ) \ - ? "loaded" \ - : ( error == SFNT_Err_Table_Missing ) \ - ? "missing" \ - : "failed to load" )); \ - FT_TRACE3(( "\n" )); \ +#define LOAD_( x ) \ + do { \ + FT_TRACE2(( "`" #x "' " )); \ + FT_TRACE3(( "-->\n" )); \ + \ + error = sfnt->load_ ## x( face, stream ); \ + \ + FT_TRACE2(( "%s\n", ( !error ) \ + ? "loaded" \ + : FT_ERR_EQ( error, Table_Missing ) \ + ? "missing" \ + : "failed to load" )); \ + FT_TRACE3(( "\n" )); \ } while ( 0 ) -#define LOADM_( x, vertical ) \ - do { \ - FT_TRACE2(( "`%s" #x "' ", \ - vertical ? "vertical " : "" )); \ - FT_TRACE3(( "-->\n" )); \ - \ - error = sfnt->load_ ## x( face, stream, vertical ); \ - \ - FT_TRACE2(( "%s\n", ( !error ) \ - ? "loaded" \ - : ( error == SFNT_Err_Table_Missing ) \ - ? "missing" \ - : "failed to load" )); \ - FT_TRACE3(( "\n" )); \ +#define LOADM_( x, vertical ) \ + do { \ + FT_TRACE2(( "`%s" #x "' ", \ + vertical ? "vertical " : "" )); \ + FT_TRACE3(( "-->\n" )); \ + \ + error = sfnt->load_ ## x( face, stream, vertical ); \ + \ + FT_TRACE2(( "%s\n", ( !error ) \ + ? "loaded" \ + : FT_ERR_EQ( error, Table_Missing ) \ + ? "missing" \ + : "failed to load" )); \ + FT_TRACE3(( "\n" )); \ } while ( 0 ) #define GET_NAME( id, field ) \ @@ -656,7 +656,7 @@ if ( !error ) { LOADM_( hmtx, 0 ); - if ( error == SFNT_Err_Table_Missing ) + if ( FT_ERR_EQ( error, Table_Missing ) ) { error = FT_THROW( Hmtx_Table_Missing ); @@ -673,7 +673,7 @@ #endif } } - else if ( error == SFNT_Err_Table_Missing ) + else if ( FT_ERR_EQ( error, Table_Missing ) ) { /* No `hhea' table necessary for SFNT Mac fonts. */ if ( face->format_tag == TTAG_true ) @@ -714,7 +714,7 @@ face->vertical_info = 1; } - if ( error && error != SFNT_Err_Table_Missing ) + if ( error && FT_ERR_NEQ( error, Table_Missing ) ) goto Exit; LOAD_( os2 ); @@ -736,7 +736,7 @@ /* a font which contains neither bitmaps nor outlines is */ /* still valid (although rather useless in most cases); */ /* however, you can find such stripped fonts in PDFs */ - if ( error == SFNT_Err_Table_Missing ) + if ( FT_ERR_EQ( error, Table_Missing ) ) error = FT_Err_Ok; else goto Exit; @@ -746,7 +746,7 @@ LOAD_( pclt ); if ( error ) { - if ( error != SFNT_Err_Table_Missing ) + if ( FT_ERR_NEQ( error, Table_Missing ) ) goto Exit; face->pclt.Version = 0; @@ -812,7 +812,7 @@ FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES - if ( psnames_error == FT_Err_Ok && + if ( !psnames_error && face->postscript.FormatType != 0x00030000L ) flags |= FT_FACE_FLAG_GLYPH_NAMES; #endif diff --git a/src/sfnt/ttbdf.c b/src/sfnt/ttbdf.c index 0e5c6746c..9401dae5f 100644 --- a/src/sfnt/ttbdf.c +++ b/src/sfnt/ttbdf.c @@ -163,7 +163,7 @@ p = bdf->table + 8; strike = p + 4 * count; - error = SFNT_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( size == NULL || property_name == NULL ) goto Exit; diff --git a/src/tools/test_afm.c b/src/tools/test_afm.c index f5f99363c..24cd0c4f0 100644 --- a/src/tools/test_afm.c +++ b/src/tools/test_afm.c @@ -118,7 +118,7 @@ if ( argc < 2 ) - return FT_Err_Invalid_Argument; + return FT_ERR( Invalid_Argument ); error = FT_Init_FreeType( &library ); if ( error ) diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index d868325b0..b6bb7487c 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -2076,7 +2076,7 @@ FT_Error error = face->goto_table( face, TTAG_glyf, stream, 0 ); - if ( FT_ERROR_BASE( error ) == FT_Err_Table_Missing ) + if ( FT_ERR_EQ( error, Table_Missing ) ) loader->glyf_offset = 0; else if ( error ) { diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index babdd7655..dd90cc88f 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -8693,11 +8693,12 @@ #endif /* TT_CONFIG_OPTION_INTERPRETER_SWITCH */ - if ( CUR.error != FT_Err_Ok ) + if ( CUR.error ) { switch ( CUR.error ) { - case TT_Err_Invalid_Opcode: /* looking for redefined instructions */ + /* looking for redefined instructions */ + case FT_ERR( Invalid_Opcode ): { TT_DefRecord* def = CUR.IDefs; TT_DefRecord* limit = def + CUR.numIDefs; diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c index 5ea8f3bda..9723a515b 100644 --- a/src/truetype/ttpload.c +++ b/src/truetype/ttpload.c @@ -72,7 +72,7 @@ /* it is possible that a font doesn't have a glyf table at all */ /* or its size is zero */ - if ( FT_ERROR_BASE( error ) == TT_Err_Table_Missing ) + if ( FT_ERR_EQ( error, Table_Missing ) ) face->glyf_len = 0; else if ( error ) goto Exit; diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c index 75d09e0e3..b2db9bff7 100644 --- a/src/type1/t1afm.c +++ b/src/type1/t1afm.c @@ -239,7 +239,7 @@ FT_Memory memory = stream->memory; AFM_ParserRec parser; AFM_FontInfo fi = NULL; - FT_Error error = T1_Err_Unknown_File_Format; + FT_Error error = FT_ERR( Unknown_File_Format ); T1_Font t1_font = &( (T1_Face)t1_face )->type1; @@ -270,7 +270,7 @@ } } - if ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format ) + if ( FT_ERR_EQ( error, Unknown_File_Format ) ) { FT_Byte* start = stream->cursor; diff --git a/src/type1/t1load.c b/src/type1/t1load.c index b8b234976..b1159eef8 100644 --- a/src/type1/t1load.c +++ b/src/type1/t1load.c @@ -372,7 +372,7 @@ FT_UInt n, m; - error = T1_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( blend && blend->num_axis == num_coords ) { @@ -421,7 +421,7 @@ FT_UInt n, p; - error = T1_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( blend && blend->num_axis == num_coords ) { /* compute the blend coordinates through the blend design map */ @@ -497,7 +497,7 @@ FT_Error error; - error = T1_Err_Invalid_Argument; + error = FT_ERR( Invalid_Argument ); if ( num_coords <= 4 && num_coords > 0 ) { for ( i = 0; i < num_coords; ++i ) @@ -579,7 +579,7 @@ T1_MAX_MM_AXIS, &num_axis ); if ( num_axis < 0 ) { - error = T1_Err_Ignore; + error = FT_ERR( Ignore ); goto Exit; } if ( num_axis == 0 || num_axis > T1_MAX_MM_AXIS ) @@ -648,7 +648,7 @@ T1_MAX_MM_DESIGNS, &num_designs ); if ( num_designs < 0 ) { - error = T1_Err_Ignore; + error = FT_ERR( Ignore ); goto Exit; } if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS ) @@ -745,7 +745,7 @@ T1_MAX_MM_AXIS, &num_axis ); if ( num_axis < 0 ) { - error = T1_Err_Ignore; + error = FT_ERR( Ignore ); goto Exit; } if ( num_axis == 0 || num_axis > T1_MAX_MM_AXIS ) @@ -836,7 +836,7 @@ T1_MAX_MM_DESIGNS, &num_designs ); if ( num_designs < 0 ) { - error = T1_Err_Ignore; + error = FT_ERR( Ignore ); goto Exit; } if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS ) @@ -1347,7 +1347,7 @@ face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1; else - parser->root.error = T1_Err_Ignore; + parser->root.error = FT_ERR( Ignore ); } } @@ -1998,7 +1998,7 @@ keyword ); if ( parser->root.error != FT_Err_Ok ) { - if ( FT_ERROR_BASE( parser->root.error ) == FT_Err_Ignore ) + if ( FT_ERR_EQ( parser->root.error, Ignore ) ) parser->root.error = FT_Err_Ok; else return parser->root.error; diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index d006d658c..837b7911d 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -517,8 +517,8 @@ charmap.encoding = FT_ENCODING_UNICODE; error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL ); - if ( error && - FT_ERROR_BASE( error ) != FT_Err_No_Unicode_Glyph_Name ) + if ( error && + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) goto Exit; error = FT_Err_Ok; diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c index a2d26a19c..f7c402e57 100644 --- a/src/type1/t1parse.c +++ b/src/type1/t1parse.c @@ -158,7 +158,7 @@ error = check_type1_format( stream, "%!PS-AdobeFont", 14 ); if ( error ) { - if ( error != T1_Err_Unknown_File_Format ) + if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) goto Exit; error = check_type1_format( stream, "%!FontType", 10 ); diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c index cb142381b..fd18b255d 100644 --- a/src/type42/t42objs.c +++ b/src/type42/t42objs.c @@ -347,8 +347,8 @@ charmap.encoding = FT_ENCODING_UNICODE; error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL ); - if ( error && - FT_ERROR_BASE( error ) != FT_Err_No_Unicode_Glyph_Name ) + if ( error && + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) goto Exit; error = FT_Err_Ok; diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c index f30dad8e9..233ea09dc 100644 --- a/src/winfonts/winfnt.c +++ b/src/winfonts/winfnt.c @@ -284,7 +284,7 @@ FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) ) goto Exit; - error = FNT_Err_Unknown_File_Format; + error = FT_ERR( Unknown_File_Format ); if ( mz_header.magic == WINFNT_MZ_MAGIC ) { /* yes, now look for an NE header in the file */ @@ -297,7 +297,7 @@ FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) ) goto Exit; - error = FNT_Err_Unknown_File_Format; + error = FT_ERR( Unknown_File_Format ); if ( ne_header.magic == WINFNT_NE_MAGIC ) { /* good, now look into the resource table for each FNT resource */ @@ -705,7 +705,7 @@ if ( !error && face_index < 0 ) goto Exit; - if ( error == FNT_Err_Unknown_File_Format ) + if ( FT_ERR_EQ( error, Unknown_File_Format ) ) { /* this didn't work; try to load a single FNT font */ FNT_Font font; @@ -920,7 +920,7 @@ FNT_Face face = (FNT_Face)size->face; FT_WinFNT_Header header = &face->font->header; FT_Bitmap_Size* bsize = size->face->available_sizes; - FT_Error error = FNT_Err_Invalid_Pixel_Size; + FT_Error error = FT_ERR( Invalid_Pixel_Size ); FT_Long height;