Formatting; adding some tracing code.
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 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
diff --git a/config/unix/ftsystem.c b/config/unix/ftsystem.c
index 0f02910..c902f4c 100644
--- a/config/unix/ftsystem.c
+++ b/config/unix/ftsystem.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * ftsystem.h 1.0
+ * ftsystem.c 1.0
*
* Unix-specific FreeType low-level system interface
*
@@ -9,7 +9,7 @@
* as thread synchronisation.
*
*
- * Copyright 1996-1999 by
+ * Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg
*
* This file is part of the FreeType project, and may only be used
@@ -208,14 +208,14 @@
if (file < 0)
{
FT_ERROR(( "FT.Unix.Open:" ));
- FT_ERROR(( " could not open '%s'\n", filepathname ));
+ FT_ERROR(( " could not open `%s'\n", filepathname ));
return FT_Err_Cannot_Open_Stream;
}
if (fstat( file, &stat_buf ) < 0)
{
FT_ERROR(( "FT.Unix.Open:" ));
- FT_ERROR(( " could not 'fstat' file '%s'\n", filepathname ));
+ FT_ERROR(( " could not `fstat' file `%s'\n", filepathname ));
goto Fail_Map;
}
@@ -231,7 +231,7 @@
if ( (long)stream->base == -1 )
{
FT_ERROR(( "FT.Unix.Open:" ));
- FT_ERROR(( " Could not map file '%s'\n", filepathname ));
+ FT_ERROR(( " Could not map file `%s'\n", filepathname ));
goto Fail_Map;
}
@@ -244,7 +244,7 @@
stream->read = 0;
FT_TRACE1(( "FT.Unix.Open:" ));
- FT_TRACE1(( " opened '%s' (%d bytes) succesfully\n",
+ FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
filepathname, stream->size ));
return FT_Err_Ok;
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index efadfc7..01528c2 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -206,8 +206,8 @@
/* */
/* Don't define any of these macros to compile in `release' mode. */
/* */
-#undef FT_DEBUG_LEVEL_ERROR
-#undef FT_DEBUG_LEVEL_TRACE
+#define FT_DEBUG_LEVEL_ERROR
+#define FT_DEBUG_LEVEL_TRACE
/*************************************************************************/
diff --git a/include/freetype/internal/ftcalc.h b/include/freetype/internal/ftcalc.h
index 7c81eab..c45fd7b 100644
--- a/include/freetype/internal/ftcalc.h
+++ b/include/freetype/internal/ftcalc.h
@@ -41,12 +41,13 @@
#define SQRT_64( z ) FT_Sqrt64( z )
- FT_EXPORT_DEF(FT_Int32) FT_Sqrt64( FT_Int64 x );
+ FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64 l );
#endif /* OLD_CALCS */
#else /* LONG64 */
+
typedef struct FT_Int64_
{
FT_Word32 lo;
@@ -58,17 +59,22 @@
#define MUL_64( x, y, z ) FT_MulTo64( x, y, &z )
#define DIV_64( x, y ) FT_Div64by32( &x, y )
- FT_EXPORT_DEF(void) FT_Add64 ( FT_Int64* x, FT_Int64* y, FT_Int64* z );
+ FT_EXPORT_DEF( void ) FT_Add64 ( FT_Int64* x,
+ FT_Int64* y,
+ FT_Int64* z );
- FT_EXPORT_DEF(void) FT_MulTo64 ( FT_Int32 x, FT_Int32 y, FT_Int64* z );
+ FT_EXPORT_DEF( void ) FT_MulTo64 ( FT_Int32 x,
+ FT_Int32 y,
+ FT_Int64* z );
- FT_EXPORT_DEF(FT_Int32) FT_Div64by32( FT_Int64* x, FT_Int32 y );
+ FT_EXPORT_DEF( FT_Int32 ) FT_Div64by32( FT_Int64* x,
+ FT_Int32 y );
#ifdef FT_CONFIG_OPTION_OLD_CALCS
#define SQRT_64( z ) FT_Sqrt64( &z )
- FT_EXPORT_DEF(FT_Int32) FT_Sqrt64( FT_Int64* x );
+ FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64* x );
#endif /* OLD_CALC */
@@ -77,10 +83,12 @@
#ifndef FT_CONFIG_OPTION_OLD_CALCS
-#define SQRT_32( x ) FT_Sqrt32( x )
+#define SQRT_32( x ) FT_Sqrt32( x )
+
+ BASE_DEF(FT_Int32) FT_Sqrt32( FT_Int32 x );
+
+#endif /* FT_CONFIG_OPTION_OLD_CALCS */
- BASE_DEF(FT_Int32) FT_Sqrt32( FT_Int32 l );
-#endif
/*************************************************************************/
/* */
@@ -95,8 +103,8 @@
#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
#define FLOAT_TO_FIXED( x ) ( (FT_Long)(x * 65536.0) )
-#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ((x) + 32) & -64) \
- : ( -((32 - (x)) & -64) ) )
+#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
+ : ( -( ( 32 - (x) ) & -64 ) ) )
#ifdef __cplusplus
}
diff --git a/include/freetype/internal/ftdebug.h b/include/freetype/internal/ftdebug.h
index c8c32ea..1a827bf 100644
--- a/include/freetype/internal/ftdebug.h
+++ b/include/freetype/internal/ftdebug.h
@@ -15,46 +15,28 @@
/* */
/***************************************************************************/
- /*************************************************************************/
- /* */
- /* This component contains various macros and functions used to ease the */
- /* debugging of the FreeType engine. Its main purpose is in assertion */
- /* checking, tracing, and error detection. */
- /* */
- /* There are now three debugging modes: */
- /* */
- /* - trace mode */
- /* */
- /* Error and trace messages are sent to the log file (which can be the */
- /* standard error output). */
- /* */
- /* - error mode */
- /* */
- /* Only error messages are generated. */
- /* */
- /* - release mode: */
- /* */
- /* No error message is sent or generated. The code is free from any */
- /* debugging parts. */
- /* */
- /*************************************************************************/
-
#ifndef FTDEBUG_H
#define FTDEBUG_H
-#include <freetype/config/ftconfig.h> /* for FT_DEBUG_LEVEL_TRACE, FT_DEBUG_LEVEL_ERROR */
-
+#include <freetype/config/ftconfig.h> /* for FT_DEBUG_LEVEL_TRACE, */
+ /* FT_DEBUG_LEVEL_ERROR */
#ifdef __cplusplus
extern "C" {
#endif
-/* A very stupid pre-processor trick. See K&R version 2 */
-/* section A12.3 for details.. */
-#define FT_CAT(x,y) x ## y
-#define FT_XCAT(x,y) FT_CAT(x,y)
+ /* A very stupid pre-processor trick. See K&R version 2 */
+ /* section A12.3 for details... */
+ /* */
+ /* It is also described in the section `Separate */
+ /* Expansion of Macro Arguments' in the info file */
+ /* `cpp.info', describing GNU cpp. */
+ /* */
+#define FT_CAT( x, y ) x ## y
+#define FT_XCAT( x, y ) FT_CAT( x, y )
+
#ifdef FT_DEBUG_LEVEL_TRACE
@@ -64,15 +46,14 @@
/* the first level must always be `trace_any' */
trace_any = 0,
- /* first, define an enum for each common component */
- trace_io, /* in ftsys */
- trace_memory, /* in ftsys */
- trace_sync, /* in ftsys */
- trace_stream, /* stream manager - see ftstream.c */
- trace_calc, /* computations - see ftcalc.c */
- trace_raster, /* raster - see ftraster.c */
- trace_list, /* list manager - see ftlist.c */
- trace_objs, /* base objects - see ftobjs.c */
+ /* we start with an enum for each common component */
+ trace_io, /* i/o monitoring -- see ftsystem.c */
+ trace_memory, /* memory manager -- see ftobjs.c */
+ trace_stream, /* stream manager -- see ftstream.c */
+ trace_calc, /* computations -- see ftcalc.c */
+ trace_raster, /* raster -- see ftraster.c */
+ trace_list, /* list manager -- see ftlist.c */
+ trace_objs, /* base objects -- see ftobjs.c */
/* then define an enum for each TrueType driver component */
trace_ttobjs,
@@ -92,6 +73,7 @@
/* other trace levels */
trace_init,
+ trace_extend,
/* the last level must always be `trace_max' */
trace_max
diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c
index dae2277..5fb000b 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -16,6 +16,31 @@
/***************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* This component contains various macros and functions used to ease the */
+ /* debugging of the FreeType engine. Its main purpose is in assertion */
+ /* checking, tracing, and error detection. */
+ /* */
+ /* There are now three debugging modes: */
+ /* */
+ /* - trace mode */
+ /* */
+ /* Error and trace messages are sent to the log file (which can be the */
+ /* standard error output). */
+ /* */
+ /* - error mode */
+ /* */
+ /* Only error messages are generated. */
+ /* */
+ /* - release mode: */
+ /* */
+ /* No error message is sent or generated. The code is free from any */
+ /* debugging parts. */
+ /* */
+ /*************************************************************************/
+
+
#include <freetype/internal/ftdebug.h>
#ifdef FT_DEBUG_LEVEL_TRACE
diff --git a/src/base/ftextend.c b/src/base/ftextend.c
index 550bf30..24d8b0e 100644
--- a/src/base/ftextend.c
+++ b/src/base/ftextend.c
@@ -27,7 +27,13 @@
#include <freetype/internal/ftextend.h>
-/* required by the tracing mode */
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_extend
@@ -71,6 +77,8 @@
registry->cur_offset = 0;
driver->extensions = registry;
+ FT_TRACE2(( "FT_Init_Extensions: success" ));
+
return FT_Err_Ok;
}
@@ -144,6 +152,9 @@
registry->num_extensions++;
registry->cur_offset += ( cur->size + FT_ALIGNMENT-1 ) & -FT_ALIGNMENT;
+
+ FT_TRACE1(( "FT_Register_Extension: `%s' successfully registered",
+ cur->id ));
}
return FT_Err_Ok;
@@ -192,12 +203,17 @@
if ( strcmp( cur->id, extension_id ) == 0 )
{
*extension_interface = cur->interface;
+
+ FT_TRACE1(( "FT_Get_Extension: got `%s'", extension_id ));
+
return (void*)((char*)face->extensions + cur->offset);
}
}
/* could not find the extension id */
+ FT_ERROR(( "FT_Get_Extension: couldn't find `%s'", extension_id ));
+
*extension_interface = 0;
return 0;
diff --git a/src/base/ftinit.c b/src/base/ftinit.c
index c24a9c7..1c3ace6 100644
--- a/src/base/ftinit.c
+++ b/src/base/ftinit.c
@@ -42,6 +42,13 @@
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftdriver.h>
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_init
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index e8d5b06..6f57347 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -19,6 +19,13 @@
#include <freetype/internal/ftstream.h>
#include <freetype/internal/ftdebug.h>
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_stream
diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c
index bf02b11..f51a504 100644
--- a/src/base/ftsystem.c
+++ b/src/base/ftsystem.c
@@ -1,6 +1,6 @@
/***************************************************************************/
/* */
-/* ftsystem.h */
+/* ftsystem.c */
/* */
/* ANSI-specific FreeType low-level system interface (body). */
/* */
@@ -26,6 +26,7 @@
#include <freetype/config/ftconfig.h>
+#include <freetype/internal/ftdebug.h>
#include <freetype/ftsystem.h>
#include <freetype/fterrors.h>
#include <freetype/fttypes.h>
@@ -137,6 +138,17 @@
/*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_io
+
+ /* We use the macro STREAM_FILE for convenience to extract the */
+ /* system-specific stream handle from a given FreeType stream object */
#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
@@ -155,6 +167,10 @@
void ft_close_stream( FT_Stream stream )
{
fclose( STREAM_FILE( stream ) );
+
+ stream->descriptor.pointer = NULL;
+ stream->size = 0;
+ stream->base = 0;
}
@@ -220,18 +236,28 @@
file = fopen( filepathname, "rb" );
if ( !file )
+ {
+ FT_ERROR(( "FT_New_Stream:" ));
+ FT_ERROR(( " could not open `%s'\n", filepathname ));
+
return FT_Err_Cannot_Open_Resource;
+ }
fseek( file, 0, SEEK_END );
stream->size = ftell( file );
fseek( file, 0, SEEK_SET );
stream->descriptor.pointer = file;
+ stream->pathname.pointer = (char*)filepathname;
stream->pos = 0;
stream->read = ft_io_stream;
stream->close = ft_close_stream;
+ FT_TRACE1(( "FT_New_Stream:" ));
+ FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
+ filepathname, stream->size ));
+
return FT_Err_Ok;
}