From 6c71c6b968139e91723cb06c91384fc8b5994165 Mon Sep 17 00:00:00 2001 From: David Turner Date: Sat, 25 Feb 2006 12:49:40 +0000 Subject: [PATCH] * include/freetype/config/ftoption.h, src/autofit/afcjk.c, src/base/ftobjs.c, src/base/ftutil.c, src/cff/cffobjs.c, src/psaux/afmparse.c, src/sfnt/ttbdf.c, src/tools/apinames.c, src/truetype/ttdriver.c: solved compiler warnings as well as C++ compilation problems --- ChangeLog | 12 +++++++++- include/freetype/config/ftoption.h | 10 ++++++++ src/autofit/afcjk.c | 11 +++++---- src/base/ftobjs.c | 7 +++--- src/base/ftutil.c | 12 ++++------ src/cff/cffobjs.c | 2 +- src/psaux/afmparse.c | 10 ++++---- src/sfnt/ttbdf.c | 12 ++++++---- src/tools/apinames.c | 38 ++++++++++++++++-------------- src/truetype/ttdriver.c | 4 ++-- 10 files changed, 71 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 503fc35d0..e66bbda16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,18 @@ +2006-02-25 David Turner + + * include/freetype/config/ftoption.h, src/autofit/afcjk.c, + src/base/ftobjs.c, src/base/ftutil.c, src/cff/cffobjs.c, + src/psaux/afmparse.c, src/sfnt/ttbdf.c, src/tools/apinames.c, + src/truetype/ttdriver.c: + + solved compiler warnings as well as C++ compilation problems + + 2006-02-24 Chia-I Wu * src/base/ftoutln.c (FT_OUTLINE_GET_CONTOUR, ft_contour_has, ft_contour_enclosed, ft_outline_get_orientation): Commented out. We - have to wait until `FT_GlyphSlot_Own_Bitmap' is stabilized. + have to wait until `FT_GlyphSlot_Own_Bitmap' is stabilized. (FT_Outline_Embolden): Use `FT_Outline_Get_Orientation'. 2006-02-24 Chia-I Wu diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h index bb1bbee6f..810e1995b 100644 --- a/include/freetype/config/ftoption.h +++ b/include/freetype/config/ftoption.h @@ -586,8 +586,13 @@ FT_BEGIN_HEADER * certain functions like ft_mem_alloc in a way that prevents recent GCC * releases from emitting zillions of `strict aliasing' warning messages * each time a memory-management function is called. + * + * note that it shouldn't be activated when compiling the library + * as C++ */ +#ifndef __cplusplus #define FT_STRICT_ALIASING +#endif /* @@ -595,6 +600,11 @@ FT_BEGIN_HEADER * structures that was used prior to FreeType 2.2. This also compiles in * a few obsolete functions to avoid linking problems on typical Unix * distributions. + * + * if you're on an embedded system, or if you're building a new + * distribution from scratch, it is recommended to disable the macro + * since it will reduce the library's code size and activate a few + * memory-saving optimizations as well. */ #define FT_CONFIG_OPTION_OLD_INTERNALS diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c index d549da52b..775f03657 100644 --- a/src/autofit/afcjk.c +++ b/src/autofit/afcjk.c @@ -131,7 +131,7 @@ { AF_Point pt = seg->first; AF_Point last = seg->last; - AF_Flags f0 = pt->flags & AF_FLAG_CONTROL; + AF_Flags f0 = (AF_Flags)(pt->flags & AF_FLAG_CONTROL); AF_Flags f1; @@ -140,7 +140,7 @@ for ( ; pt != last; f0 = f1 ) { pt = pt->next; - f1 = pt->flags & AF_FLAG_CONTROL; + f1 = (AF_Flags)(pt->flags & AF_FLAG_CONTROL); if ( !f0 && !f1 ) break; @@ -921,7 +921,9 @@ org_len = edge2->opos - edge->opos; cur_len = af_cjk_compute_stem_width( hints, dim, org_len, - edge->flags, edge2->flags ); + (AF_Edge_Flags)edge->flags, + (AF_Edge_Flags)edge2->flags ); + org_center = ( edge->opos + edge2->opos ) / 2 + anchor; cur_pos1 = org_center - cur_len / 2; cur_pos2 = cur_pos1 + cur_len; @@ -1123,7 +1125,8 @@ #endif /* 0 */ - delta = af_hint_normal_stem( hints, edge, edge2, 0, 0 ); + delta = af_hint_normal_stem( hints, edge, edge2, 0, + AF_DIMENSION_HORZ ); } else af_hint_normal_stem( hints, edge, edge2, delta, dim ); diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index a326714af..6ed420a4f 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -2125,7 +2125,7 @@ if ( FT_IS_SCALABLE( face ) ) { - FT_Long w, h, scaled_w, scaled_h; + FT_Long w, h, scaled_w = 0, scaled_h = 0; switch ( req->type ) @@ -3688,8 +3688,9 @@ FT_Service_TrueTypeEngine service; - service = ft_module_get_service( module, - FT_SERVICE_ID_TRUETYPE_ENGINE ); + service = (FT_Service_TrueTypeEngine) + ft_module_get_service( module, + FT_SERVICE_ID_TRUETYPE_ENGINE ); if ( service ) result = service->engine_type; } diff --git a/src/base/ftutil.c b/src/base/ftutil.c index efc23144b..31d3a1c65 100644 --- a/src/base/ftutil.c +++ b/src/base/ftutil.c @@ -334,16 +334,15 @@ FT_BASE_DEF( void ) ft_mem_free( FT_Memory memory, - void** P ) + void* *P ) { FT_TRACE7(( "ft_mem_free:" )); - FT_TRACE7(( " Freeing block 0x%08p, ref 0x%08p\n", - P, P ? *P : (void*)0 )); + FT_TRACE7(( " Freeing block 0x%08p ref 0x%08p\n", P, *P )); if ( P && *P ) { memory->free( memory, *P ); - *P = 0; + *P = NULL; } } @@ -623,10 +622,7 @@ void* *P ) { if ( *P ) - { - ft_mem_free( memory, *P ); - *P = NULL; - } + FT_MEM_FREE( *P ); } #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index 08a165bc3..4ddbc3a69 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -206,7 +206,7 @@ if ( FT_HAS_FIXED_SIZES( size->face ) ) { CFF_Face cffface = (CFF_Face)size->face; - SFNT_Service sfnt = cffface->sfnt; + SFNT_Service sfnt = (SFNT_Service)cffface->sfnt; FT_ULong index; diff --git a/src/psaux/afmparse.c b/src/psaux/afmparse.c index eae048b1c..012ff8c75 100644 --- a/src/psaux/afmparse.c +++ b/src/psaux/afmparse.c @@ -513,7 +513,7 @@ return AFM_TOKEN_UNKNOWN; if ( ft_strncmp( afm_key_table[n], key, len ) == 0 ) - return n; + return (AFM_Token) n; } } } @@ -578,7 +578,7 @@ else return PSaux_Err_Syntax_Error; } - + static FT_Error afm_parse_track_kern( AFM_Parser parser ) @@ -606,7 +606,7 @@ while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 ) { AFM_ValueRec shared_vals[5]; - + switch ( afm_tokenize( key, len ) ) { @@ -796,7 +796,7 @@ break; case AFM_TOKEN_ENDKERNDATA: - case AFM_TOKEN_ENDFONTMETRICS: + case AFM_TOKEN_ENDFONTMETRICS: return PSaux_Err_Ok; case AFM_TOKEN_UNKNOWN: @@ -940,7 +940,7 @@ goto Fail; /* fall through since we only support kern data */ - case AFM_TOKEN_ENDFONTMETRICS: + case AFM_TOKEN_ENDFONTMETRICS: return PSaux_Err_Ok; break; diff --git a/src/sfnt/ttbdf.c b/src/sfnt/ttbdf.c index 52bbce09e..9372384d8 100644 --- a/src/sfnt/ttbdf.c +++ b/src/sfnt/ttbdf.c @@ -92,11 +92,7 @@ ( strings - 8 ) / 4 < num_strikes || strings + 1 > length ) { - BadTable: - FT_FRAME_RELEASE( bdf->table ); - FT_ZERO( bdf ); - error = FT_Err_Invalid_Table; - goto Exit; + goto BadTable; } bdf->num_strikes = num_strikes; @@ -132,6 +128,12 @@ Exit: return error; + + BadTable: + FT_FRAME_RELEASE( bdf->table ); + FT_ZERO( bdf ); + error = FT_Err_Invalid_Table; + goto Exit; } diff --git a/src/tools/apinames.c b/src/tools/apinames.c index 51668a022..2d8583f6d 100644 --- a/src/tools/apinames.c +++ b/src/tools/apinames.c @@ -86,14 +86,14 @@ names_add( const char* name, if ( num_names >= max_names ) { max_names += (max_names >> 1) + 4; - the_names = realloc( the_names, sizeof(the_names[0])*max_names ); + the_names = (NameRec*)realloc( the_names, sizeof(the_names[0])*max_names ); if ( the_names == NULL ) panic( "not enough memory" ); } nm = &the_names[num_names++]; nm->hash = h; - nm->name = malloc( len+1 ); + nm->name = (char*)malloc( len+1 ); if ( nm->name == NULL ) panic( "not enough memory" ); @@ -289,23 +289,25 @@ read_header_file( FILE* file, int verbose ) static void usage( void ) { + static const char* const format = + "%s %s: extract FreeType API names from header files\n\n" + "this program is used to extract the list of public FreeType API\n" + "functions. It receives the list of header files as argument and\n" + "generates a sorted list of unique identifiers\n\n" + + "usage: %s header1 [options] [header2 ...]\n\n" + + "options: - : parse the content of stdin, ignore arguments\n" + " -v : verbose mode, output sent to standard error\n" + " -oFILE : write output to FILE instead of standard output\n" + " -dNAME : indicate DLL file name, 'freetype.dll' by default\n" + " -w : output .DEF file for Visual C++ and Mingw\n" + " -wB : output .DEF file for Borland C++\n" + " -wW : output Watcom Linker Response File\n" + "\n"; + fprintf( stderr, - "%s %s: extract FreeType API names from header files\n\n" - "this program is used to extract the list of public FreeType API\n" - "functions. It receives the list of header files as argument and\n" - "generates a sorted list of unique identifiers\n\n" - - "usage: %s header1 [options] [header2 ...]\n\n" - - "options: - : parse the content of stdin, ignore arguments\n" - " -v : verbose mode, output sent to standard error\n", - " -oFILE : write output to FILE instead of standard output\n" - " -dNAME : indicate DLL file name, 'freetype.dll' by default\n" - " -w : output .DEF file for Visual C++ and Mingw\n" - " -wB : output .DEF file for Borland C++\n" - " -wW : output Watcom Linker Response File\n" - "\n" - , + format, PROGRAM_NAME, PROGRAM_VERSION, PROGRAM_NAME diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index a29c38ac9..fa25c25ed 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -158,7 +158,7 @@ } else { - SFNT_Service sfnt = ttface->sfnt; + SFNT_Service sfnt = (SFNT_Service) ttface->sfnt; FT_Size_Metrics* metrics = &size->metrics; @@ -186,7 +186,7 @@ if ( FT_HAS_FIXED_SIZES( size->face ) ) { TT_Face ttface = (TT_Face)size->face; - SFNT_Service sfnt = ttface->sfnt; + SFNT_Service sfnt = (SFNT_Service) ttface->sfnt; FT_ULong index;