* 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
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
diff --git a/ChangeLog b/ChangeLog
index 503fc35..e66bbda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,18 @@
+2006-02-25 David Turner <david@freetype.org>
+
+ * 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 <b90201047@ntu.edu.tw>
* 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 <b90201047@ntu.edu.tw>
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index bb1bbee..810e199 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 d549da5..775f036 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 a326714..6ed420a 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 efc2314..31d3a1c 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 08a165b..4ddbc3a 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 eae048b..012ff8c 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 52bbce0..9372384 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 51668a0..2d8583f 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 a29c38a..fa25c25 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;