ref: 6a681fa84a0ba1164726cedfc3623d84f1e3d60a
parent: 97c64185603a94d8251255a4325d2464aad72918
author: David Turner <[email protected]>
date: Fri Jan 27 07:11:22 EST 2006
* src/autofit/afwarp.c: simple #ifdef to prevent compilation when the warp hinter isn't active (it shouldn't, still experimental) * Jamfile, include/freetype/config/ftmodule.h: removed "gxvalid" and "otvalid" from the list of modules that are linked statically to a given FreeType library. Functionality has been moved to the "ftvalid" CVS module. note also that current Make-based build system still compiles the modules though... * include/freetype/config/ftoption.h: added FT_STRICT_ALIASING, which controls the definitions of the memory management functions to avoid warnings with recent versions of GCC. this macro is only here to be disabled, in case we detect problems with the new scheme. NOTE: disable macro to use the memory debugger. this will be fixed later !!
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
2006-01-27 David Turner <[email protected]>
+ * src/autofit/afwarp.c: simple #ifdef to prevent compilation when
+ the warp hinter isn't active (it shouldn't, still experimental)
+
+ * Jamfile, include/freetype/config/ftmodule.h: removed "gxvalid"
+ and "otvalid" from the list of modules that are linked statically
+ to a given FreeType library. Functionality has been moved to the
+ "ftvalid" CVS module.
+
+ note also that current Make-based build system still compiles the
+ modules though...
+
+ * include/freetype/config/ftoption.h: added FT_STRICT_ALIASING,
+ which controls the definitions of the memory management functions
+ to avoid warnings with recent versions of GCC. this macro is
+ only here to be disabled, in case we detect problems with the
+ new scheme.
+
+ NOTE: disable macro to use the memory debugger. this will be fixed
+ later !!
+
+ * builds/win32/visualc/freetype.dsp: updating project file to
+ define FT2_BUILD_LIBRARY, and remove gxvalid+otvalid from
+ compilation
+
* builds/freetype.mk, Jamfile: define the macro FT2_BUILD_LIBRARY
when compiling the library.
--- a/Jamfile
+++ b/Jamfile
@@ -76,10 +76,10 @@
cache # cache sub-system
cff # CFF/CEF font driver
cid # PostScript CID-keyed font driver
- gxvalid # validation of TrueTypeGX/AAT tables
+ #gxvalid # validation of TrueTypeGX/AAT tables
gzip # support for gzip-compressed files
lzw # support for LZW-compressed files
- otvalid # validation of OpenType tables
+ #otvalid # validation of OpenType tables
pcf # PCF font driver
pfr # PFR/TrueDoc font driver
psaux # common PostScript routines module
--- a/include/freetype/config/ftmodule.h
+++ b/include/freetype/config/ftmodule.h
@@ -15,6 +15,4 @@
FT_USE_MODULE(ft_smooth_renderer_class)
FT_USE_MODULE(ft_smooth_lcd_renderer_class)
FT_USE_MODULE(ft_smooth_lcdv_renderer_class)
-FT_USE_MODULE(otv_module_class)
FT_USE_MODULE(bdf_driver_class)
-FT_USE_MODULE(gxv_module_class)
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -561,7 +561,14 @@
* reducing the heap footprint of memory-mapped TrueType files.
*
*/
-/* #define FT_OPTIMIZE_MEMORY */
+#define FT_OPTIMIZE_MEMORY
+
+/* this temporary macro is used to control wether we're going to
+ * compile certain functions like FT_Alloc in a way that prevent recent
+ * GCC releases from spouting horrible "strict aliasing" warning
+ * messages each time a memory-management function is called
+ */
+#define FT_STRICT_ALIASING
FT_END_HEADER
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -56,8 +56,141 @@
/*************************************************************************/
/*************************************************************************/
-#ifdef FT_DEBUG_MEMORY
+#ifdef FT_STRICT_ALIASING
+ /* the allocation functions return a pointer, and the error code
+ * is written to through the 'p_error' parameter
+ */
+
+ FT_BASE( FT_Pointer )
+ FT_Alloc( FT_Memory memory,
+ FT_Long size,
+ FT_Error *p_error );
+
+ FT_BASE( FT_Pointer )
+ FT_QAlloc( FT_Memory memory,
+ FT_Long size,
+ FT_Error *p_error );
+
+ FT_BASE( FT_Pointer )
+ FT_Realloc( FT_Memory memory,
+ FT_Long current,
+ FT_Long size,
+ void* block,
+ FT_Error *p_error );
+
+ FT_BASE( FT_Pointer )
+ FT_QRealloc( FT_Memory memory,
+ FT_Long current,
+ FT_Long size,
+ void* block,
+ FT_Error *p_error );
+
+ FT_BASE( void )
+ FT_Free( FT_Memory memory,
+ const void* P );
+
+
+# ifdef FT_DEBUG_MEMORY
+
+ FT_BASE( FT_Pointer )
+ FT_Alloc_Debug( FT_Memory memory,
+ FT_Long size,
+ FT_Error *p_error,
+ const char* file_name,
+ FT_Long line_no );
+
+ FT_BASE( FT_Pointer )
+ FT_QAlloc_Debug( FT_Memory memory,
+ FT_Long size,
+ void* P,
+ FT_Error *p_error,
+ const char* file_name,
+ FT_Long line_no );
+
+ FT_BASE( FT_Pointer )
+ FT_Realloc_Debug( FT_Memory memory,
+ FT_Long current,
+ FT_Long size,
+ void* P,
+ FT_Error *p_error,
+ const char* file_name,
+ FT_Long line_no );
+
+ FT_BASE( FT_Pointer )
+ FT_QRealloc_Debug( FT_Memory memory,
+ FT_Long current,
+ FT_Long size,
+ void* P,
+ FT_Error *p_error,
+ const char* file_name,
+ FT_Long line_no );
+
+ FT_BASE( void )
+ FT_Free_Debug( FT_Memory memory,
+ FT_Pointer block,
+ const char* file_name,
+ FT_Long line_no );
+
+# define FT_MEM_ALLOC( _pointer_, _size_ ) \
+ (_pointer_) = FT_Alloc_Debug( memory, _size_, &error, \
+ __FILE__, __LINE__ )
+
+# define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \
+ (_pointer_) = FT_Realloc_Debug( memory, _current_, _size_, \
+ (_pointer_), &error, \
+ __FILE__, __LINE__ )
+
+# define FT_MEM_QALLOC( _pointer_, _size_ ) \
+ (_pointer_) = FT_QAlloc_Debug( memory, _size_, &error, \
+ __FILE__, __LINE__ )
+
+# define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \
+ (_pointer_) = FT_QRealloc_Debug( memory, _current_, _size_, \
+ (_pointer_), &error, \
+ __FILE__, __LINE__ )
+
+# define FT_MEM_FREE( _pointer_ ) \
+ FT_BEGIN_STMNT \
+ if ( _pointer_ ) { \
+ FT_Free_Debug( memory, (_pointer_), __FILE__, __LINE__ ); \
+ (_pointer_) = NULL; \
+ } \
+ FT_END_STMNT
+
+
+# else /* !FT_DEBUG_MEMORY */
+
+# define FT_MEM_ALLOC( _pointer_, _size_ ) \
+ (_pointer_) = FT_Alloc( memory, _size_, &error )
+
+# define FT_MEM_FREE( _pointer_ ) \
+ FT_BEGIN_STMNT \
+ if ( (_pointer_) ) { \
+ FT_Free( memory, (_pointer_) ); \
+ (_pointer_) = NULL; \
+ } \
+ FT_END_STMNT
+
+# define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \
+ (_pointer_) = FT_Realloc( memory, _current_, _size_, \
+ (_pointer_), &error )
+
+# define FT_MEM_QALLOC( _pointer_, _size_ ) \
+ (_pointer_) = FT_QAlloc( memory, _size_, &error )
+
+# define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \
+ (_pointer_) = FT_QRealloc( memory, _current_, _size_, \
+ (_pointer_), &error )
+
+# endif /* !FT_DEBUG_MEMORY */
+
+# define FT_MEM_SET_ERROR(cond) ( (cond), error != 0 )
+
+#else /* !FT_STRICT_ALIASING */
+
+# ifdef FT_DEBUG_MEMORY
+
FT_BASE( FT_Error )
FT_Alloc_Debug( FT_Memory memory,
FT_Long size,
@@ -94,9 +227,10 @@
const char* file_name,
FT_Long line_no );
-#endif
+# endif /* FT_DEBUG_MEMORY */
+
/*************************************************************************/
/* */
/* <Function> */
@@ -249,45 +383,6 @@
FT_Free( FT_Memory memory,
void* *P );
-
-#define FT_MEM_SET( dest, byte, count ) ft_memset( dest, byte, count )
-
-#define FT_MEM_COPY( dest, source, count ) ft_memcpy( dest, source, count )
-
-#define FT_MEM_MOVE( dest, source, count ) ft_memmove( dest, source, count )
-
-
-#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count )
-
-#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) )
-
-#define FT_ARRAY_ZERO( dest, count ) \
- FT_MEM_ZERO( dest, (count) * sizeof ( *(dest) ) )
-
-#define FT_ARRAY_COPY( dest, source, count ) \
- FT_MEM_COPY( dest, source, (count) * sizeof ( *(dest) ) )
-
-#define FT_ARRAY_MOVE( dest, source, count ) \
- FT_MEM_MOVE( dest, source, (count) * sizeof ( *(dest) ) )
-
-
- /*
- * Return the maximum number of adressable elements in an array.
- * We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid
- * any problems.
- */
-#define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) )
-
-#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) )
-
-
- /*************************************************************************/
- /* */
- /* We first define FT_MEM_ALLOC, FT_MEM_REALLOC, and FT_MEM_FREE. All */
- /* macros use an _implicit_ `memory' parameter to access the current */
- /* memory allocator. */
- /* */
-
#ifdef FT_DEBUG_MEMORY
#define FT_MEM_ALLOC( _pointer_, _size_ ) \
@@ -340,7 +435,44 @@
#endif /* !FT_DEBUG_MEMORY */
+# define FT_MEM_SET_ERROR(cond) ( (error = (cond)) != 0 )
+#endif /* !FT_STRICT_ALIASING */
+
+
+
+#define FT_MEM_SET( dest, byte, count ) ft_memset( dest, byte, count )
+
+#define FT_MEM_COPY( dest, source, count ) ft_memcpy( dest, source, count )
+
+#define FT_MEM_MOVE( dest, source, count ) ft_memmove( dest, source, count )
+
+
+#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count )
+
+#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) )
+
+#define FT_ARRAY_ZERO( dest, count ) \
+ FT_MEM_ZERO( dest, (count) * sizeof ( *(dest) ) )
+
+#define FT_ARRAY_COPY( dest, source, count ) \
+ FT_MEM_COPY( dest, source, (count) * sizeof ( *(dest) ) )
+
+#define FT_ARRAY_MOVE( dest, source, count ) \
+ FT_MEM_MOVE( dest, source, (count) * sizeof ( *(dest) ) )
+
+
+ /*
+ * Return the maximum number of adressable elements in an array.
+ * We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid
+ * any problems.
+ */
+#define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) )
+
+#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) )
+
+
+
/*************************************************************************/
/* */
/* The following functions macros expect that their pointer argument is */
@@ -388,17 +520,19 @@
/* if an error occured (i.e. if 'error != 0'). */
/* */
+
+
#define FT_ALLOC( _pointer_, _size_ ) \
- FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, _size_ ) )
+ FT_MEM_SET_ERROR( FT_MEM_ALLOC( _pointer_, _size_ ) )
#define FT_REALLOC( _pointer_, _current_, _size_ ) \
- FT_SET_ERROR( FT_MEM_REALLOC( _pointer_, _current_, _size_ ) )
+ FT_MEM_SET_ERROR( FT_MEM_REALLOC( _pointer_, _current_, _size_ ) )
#define FT_QALLOC( _pointer_, _size_ ) \
- FT_SET_ERROR( FT_MEM_QALLOC( _pointer_, _size_ ) )
+ FT_MEM_SET_ERROR( FT_MEM_QALLOC( _pointer_, _size_ ) )
#define FT_QREALLOC( _pointer_, _current_, _size_ ) \
- FT_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) )
+ FT_MEM_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) )
#define FT_FREE( _pointer_ ) \
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -695,35 +695,6 @@
typedef struct AFM_ParserRec_* AFM_Parser;
- typedef struct AFM_TrackKernRec_
- {
- FT_Int degree;
- FT_Fixed min_ptsize;
- FT_Fixed min_kern;
- FT_Fixed max_ptsize;
- FT_Fixed max_kern;
-
- } AFM_TrackKernRec, *AFM_TrackKern;
-
- typedef struct AFM_KernPairRec_
- {
- FT_Int index1;
- FT_Int index2;
- FT_Int x;
- FT_Int y;
-
- } AFM_KernPairRec, *AFM_KernPair;
-
- typedef struct AFM_FontInfoRec_
- {
- FT_Bool IsCIDFont;
- AFM_TrackKern TrackKerns; /* free if non-NULL */
- FT_Int NumTrackKern;
- AFM_KernPair KernPairs; /* free if non-NULL */
- FT_Int NumKernPair;
-
- } AFM_FontInfoRec, *AFM_FontInfo;
-
typedef struct AFM_Parser_FuncsRec_
{
FT_Error
@@ -741,7 +712,6 @@
} AFM_Parser_FuncsRec;
typedef struct AFM_StreamRec_* AFM_Stream;
-
/*************************************************************************/
/* */
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -134,6 +134,48 @@
/*************************************************************************/
/*** ***/
/*** ***/
+ /*** AFM FONT INFORMATION STRUCTURES ***/
+ /*** ***/
+ /*** ***/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ typedef struct AFM_TrackKernRec_
+ {
+ FT_Int degree;
+ FT_Fixed min_ptsize;
+ FT_Fixed min_kern;
+ FT_Fixed max_ptsize;
+ FT_Fixed max_kern;
+
+ } AFM_TrackKernRec, *AFM_TrackKern;
+
+ typedef struct AFM_KernPairRec_
+ {
+ FT_Int index1;
+ FT_Int index2;
+ FT_Int x;
+ FT_Int y;
+
+ } AFM_KernPairRec, *AFM_KernPair;
+
+ typedef struct AFM_FontInfoRec_
+ {
+ FT_Bool IsCIDFont;
+ AFM_TrackKern TrackKerns; /* free if non-NULL */
+ FT_Int NumTrackKern;
+ AFM_KernPair KernPairs; /* free if non-NULL */
+ FT_Int NumKernPair;
+
+ } AFM_FontInfoRec, *AFM_FontInfo;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*** ***/
+ /*** ***/
/*** ORIGINAL T1_FACE CLASS DEFINITION ***/
/*** ***/
/*** ***/
--- a/src/autofit/afwarp.c
+++ b/src/autofit/afwarp.c
@@ -18,6 +18,7 @@
#include "afwarp.h"
+#ifdef AF_USE_WARPER
#if 1
static const AF_WarpScore
@@ -303,5 +304,10 @@
*a_delta = warper->best_delta;
}
+#else /* !AF_USE_WARPER */
+
+char af_warper_dummy = 0; /* make compiler happy */
+
+#endif /* !AF_USE_WARPER */
/* END */
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -73,10 +73,10 @@
target_size = (FT_ULong)( target_pitch * target->rows );
if ( target_size != size )
- FT_QREALLOC( target->buffer, target_size, size );
+ (void)FT_QREALLOC( target->buffer, target_size, size );
}
else
- FT_QALLOC( target->buffer, size );
+ (void)FT_QALLOC( target->buffer, size );
if ( !error )
{
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -267,7 +267,8 @@
ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot,
FT_ULong size )
{
- FT_Memory memory = FT_FACE_MEMORY( slot->face );
+ FT_Memory memory = FT_FACE_MEMORY( slot->face );
+ FT_Error error;
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
@@ -275,7 +276,8 @@
else
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
- return FT_MEM_ALLOC( slot->bitmap.buffer, size );
+ (void)FT_ALLOC( slot->bitmap.buffer, size );
+ return error;
}
@@ -895,7 +897,7 @@
FT_Driver_Class clazz;
FT_Face face = 0;
FT_Error error, error2;
- FT_Face_Internal internal;
+ FT_Face_Internal internal = NULL;
clazz = driver->clazz;
@@ -1722,10 +1724,10 @@
if ( FT_IS_SCALABLE( face ) )
{
if ( face->height < 0 )
- face->height = -face->height;
+ face->height = (short)-face->height;
if ( !FT_HAS_VERTICAL( face ) )
- face->max_advance_height = face->height;
+ face->max_advance_height = (short)face->height;
}
if ( FT_HAS_FIXED_SIZES( face ) )
@@ -1739,9 +1741,9 @@
if ( bsize->height < 0 )
- bsize->height = -bsize->height;
+ bsize->height = (FT_Short) -bsize->height;
if ( bsize->x_ppem < 0 )
- bsize->x_ppem = -bsize->x_ppem;
+ bsize->x_ppem = (FT_Short) -bsize->x_ppem;
if ( bsize->y_ppem < 0 )
bsize->y_ppem = -bsize->y_ppem;
}
@@ -2085,8 +2087,8 @@
metrics = &face->size->metrics;
bsize = face->available_sizes + strike_index;
- metrics->x_ppem = ( bsize->x_ppem + 32 ) >> 6;
- metrics->y_ppem = ( bsize->y_ppem + 32 ) >> 6;
+ metrics->x_ppem = (FT_UShort)(( bsize->x_ppem + 32 ) >> 6);
+ metrics->y_ppem = (FT_UShort)(( bsize->y_ppem + 32 ) >> 6);
if ( FT_IS_SCALABLE( face ) )
{
@@ -2197,8 +2199,8 @@
scaled_h = FT_MulFix( face->units_per_EM, metrics->y_scale );
}
- metrics->x_ppem = ( scaled_w + 32 ) >> 6;
- metrics->y_ppem = ( scaled_h + 32 ) >> 6;
+ metrics->x_ppem = (FT_UShort)(( scaled_w + 32 ) >> 6);
+ metrics->y_ppem = (FT_UShort)(( scaled_h + 32 ) >> 6);
ft_recompute_scaled_metrics( face, metrics );
}
--- a/src/base/ftrfork.c
+++ b/src/base/ftrfork.c
@@ -657,7 +657,7 @@
char* tmp;
const char* slash;
unsigned new_length;
- FT_ULong error = FT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
--- a/src/base/ftutil.c
+++ b/src/base/ftutil.c
@@ -45,6 +45,133 @@
/*************************************************************************/
/*************************************************************************/
+#ifdef FT_STRICT_ALIASING
+
+
+ FT_BASE_DEF( FT_Pointer )
+ FT_Alloc( FT_Memory memory,
+ FT_Long size,
+ FT_Error *p_error )
+ {
+ FT_Error error = 0;
+ FT_Pointer block = NULL;
+
+ if ( size > 0 )
+ {
+ block = memory->alloc( memory, size );
+ if ( block == NULL )
+ error = FT_Err_Out_Of_Memory;
+ else
+ FT_MEM_ZERO( block, size );
+ }
+ *p_error = error;
+ return block;
+ }
+
+
+ FT_BASE_DEF( FT_Pointer )
+ FT_QAlloc( FT_Memory memory,
+ FT_Long size,
+ FT_Error *p_error )
+ {
+ FT_Error error = 0;
+ FT_Pointer block = NULL;
+
+ if ( size > 0 )
+ {
+ block = memory->alloc( memory, size );
+ if ( block == NULL )
+ error = FT_Err_Out_Of_Memory;
+ }
+ *p_error = error;
+ return block;
+ }
+
+
+ FT_BASE_DEF( FT_Pointer )
+ FT_Realloc( FT_Memory memory,
+ FT_Long current,
+ FT_Long size,
+ void* block,
+ FT_Error *p_error )
+ {
+ FT_Error error = 0;
+
+ if ( size <= 0 )
+ {
+ FT_Free( memory, block );
+ block = NULL;
+ }
+ else if ( current <= 0 )
+ {
+ FT_ASSERT( block == NULL );
+
+ block = FT_Alloc( memory, size, &error );
+ }
+ else
+ {
+ FT_Pointer block2;
+
+ block2 = memory->realloc( memory, current, size, block );
+ if ( block2 == NULL )
+ error = FT_Err_Out_Of_Memory;
+ else
+ {
+ block = block2;
+ if ( size > current )
+ FT_MEM_ZERO( (char*)block + current, size-current );
+ }
+ }
+ *p_error = error;
+ return block;
+ }
+
+
+ FT_BASE_DEF( FT_Pointer )
+ FT_QRealloc( FT_Memory memory,
+ FT_Long current,
+ FT_Long size,
+ void* block,
+ FT_Error *p_error )
+ {
+ FT_Error error = 0;
+
+ if ( size <= 0 )
+ {
+ FT_Free( memory, block );
+ block = NULL;
+ }
+ else if ( current <= 0 )
+ {
+ FT_ASSERT( block == NULL );
+
+ block = FT_QAlloc( memory, size, &error );
+ }
+ else
+ {
+ FT_Pointer block2;
+
+ block2 = memory->realloc( memory, current, size, block );
+ if ( block2 == NULL )
+ error = FT_Err_Out_Of_Memory;
+ else
+ block = block2;
+ }
+ *p_error = error;
+ return block;
+
+ }
+
+ FT_BASE_DEF( void )
+ FT_Free( FT_Memory memory,
+ const void *P )
+ {
+ if ( P )
+ memory->free( memory, (void*)P );
+ }
+
+#else /* !FT_STRICT_ALIASING */
+
/* documentation is in ftmemory.h */
FT_BASE_DEF( FT_Error )
@@ -207,6 +334,8 @@
*P = 0;
}
}
+
+#endif /* !FT_STRICT_ALIASING */
/*************************************************************************/
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -249,7 +249,9 @@
if ( !parts || !len )
{
- FT_ALLOC( face->style_name, ft_strlen( "Regular" ) + 1 );
+ if ( FT_ALLOC( face->style_name, ft_strlen( "Regular" ) + 1 ) )
+ return error;
+
ft_strcpy( face->style_name, "Regular" );
}
else
--- a/src/cache/ftccache.c
+++ b/src/cache/ftccache.c
@@ -100,10 +100,11 @@
if ( p >= mask )
{
FT_Memory memory = cache->memory;
+ FT_Error error;
/* if we can't expand the array, leave immediately */
- if ( FT_MEM_RENEW_ARRAY( cache->buckets, (mask+1)*2, (mask+1)*4 ) )
+ if ( FT_RENEW_ARRAY( cache->buckets, (mask+1)*2, (mask+1)*4 ) )
break;
}
@@ -152,11 +153,12 @@
if ( p == 0 )
{
FT_Memory memory = cache->memory;
+ FT_Error error;
/* if we can't shrink the array, leave immediately */
- if ( FT_MEM_RENEW_ARRAY( cache->buckets,
- ( mask + 1 ) * 2, mask + 1 ) )
+ if ( FT_RENEW_ARRAY( cache->buckets,
+ ( mask + 1 ) * 2, mask + 1 ) )
break;
cache->mask >>= 1;
@@ -320,6 +322,7 @@
ftc_cache_init( FTC_Cache cache )
{
FT_Memory memory = cache->memory;
+ FT_Error error;
cache->p = 0;
@@ -326,7 +329,8 @@
cache->mask = FTC_HASH_INITIAL_SIZE - 1;
cache->slack = FTC_HASH_INITIAL_SIZE * FTC_HASH_MAX_LOAD;
- return ( FT_MEM_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 ) );
+ (void)FT_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 );
+ return error;
}
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2610,9 +2610,9 @@
glyph->root.linearHoriAdvance = decoder.glyph_width;
glyph->root.internal->glyph_transformed = 0;
- has_vertical_info = face->vertical_info &&
- face->vertical.number_Of_VMetrics > 0 &&
- face->vertical.long_metrics != 0;
+ has_vertical_info = FT_BOOL( face->vertical_info &&
+ face->vertical.number_Of_VMetrics > 0 &&
+ face->vertical.long_metrics != 0 );
/* get the vertical metrics from the vtmx table if we have one */
if ( has_vertical_info )
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -2294,7 +2294,7 @@
for ( idx = 0; idx < font->num_subfonts; idx++ )
cff_subfont_done( memory, font->subfonts[idx] );
- FT_FREE( font->subfonts );
+ /* FT_FREE( font->subfonts ); -- bug this is a static array !! */
}
cff_encoding_done( &font->encoding );
--- a/src/gzip/ftgzip.c
+++ b/src/gzip/ftgzip.c
@@ -99,12 +99,12 @@
uInt size )
{
FT_ULong sz = (FT_ULong)size * items;
+ FT_Error error;
FT_Pointer p;
- FT_MEM_ALLOC( p, sz );
-
- return (voidpf) p;
+ (void)FT_ALLOC( p, sz );
+ return p;
}
--- a/src/otvalid/otvcommn.c
+++ b/src/otvalid/otvcommn.c
@@ -222,9 +222,9 @@
OTV_LIMIT_CHECK( 2 );
- OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
-
GlyphCount = FT_NEXT_USHORT( p );
+
+ OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
OTV_LIMIT_CHECK( GlyphCount * 2 ); /* ClassValueArray */
}
--- a/src/otvalid/otvgpos.c
+++ b/src/otvalid/otvgpos.c
@@ -67,9 +67,9 @@
OTV_LIMIT_CHECK( 2 );
- OTV_TRACE(( " (Count = %d)\n", Count ));
-
Count = FT_NEXT_USHORT( p );
+
+ OTV_TRACE(( " (Count = %d)\n", Count ));
OTV_LIMIT_CHECK( Count * valid->extra1 * 2 );
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -213,7 +213,7 @@
FT_FREE( prop->name );
if ( prop->isString )
- FT_FREE( prop->value );
+ FT_FREE( prop->value.atom );
}
FT_FREE( face->properties );
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -480,7 +480,7 @@
FT_UInt probe = power * size;
FT_UInt extra = count - power;
FT_Byte* base = stream->cursor;
- FT_Bool twobytes = item->flags & 1;
+ FT_Bool twobytes = FT_BOOL(item->flags & 1);
FT_Byte* p;
FT_UInt32 cpair;
--- a/src/psaux/Jamfile
+++ b/src/psaux/Jamfile
@@ -16,7 +16,9 @@
if $(FT2_MULTI)
{
- _sources = psauxmod psobjs t1decode t1cmap ;
+ _sources = psauxmod psobjs t1decode t1cmap
+ psconv afmparse
+ ;
}
else
{
--- a/src/psaux/afmparse.c
+++ b/src/psaux/afmparse.c
@@ -15,7 +15,8 @@
/* */
/***************************************************************************/
-
+#include <ft2build.h>
+#include FT_FREETYPE_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_DEBUG_H
@@ -90,7 +91,7 @@
static int
afm_stream_skip_spaces( AFM_Stream stream )
{
- int ch;
+ int ch = 0; /* make stupid compiler happy */
if ( AFM_STATUS_EOC( stream ) )
@@ -277,7 +278,7 @@
} AFM_Token;
- static const char* afm_key_table[N_AFM_TOKENS] =
+ static const char* const afm_key_table[N_AFM_TOKENS] =
{
"Ascender",
"AxisLabel",
@@ -356,11 +357,6 @@
};
-#define AFM_MAX_ARGUMENTS 5
-
- static AFM_ValueRec shared_vals[AFM_MAX_ARGUMENTS];
-
-
/*
* `afm_parser_read_vals' and `afm_parser_next_key' provide
* high-level operations to an AFM_Stream. The rest of the
@@ -401,12 +397,16 @@
{
case AFM_VALUE_TYPE_STRING:
case AFM_VALUE_TYPE_NAME:
- if ( !FT_QAlloc( parser->memory, len + 1,
- (void**)&(val->u.s) ) )
- {
- ft_memcpy( val->u.s, str, len );
- val->u.s[len] = '\0';
- }
+ {
+ FT_Memory memory = parser->memory;
+ FT_Error error;
+
+ if ( !FT_QALLOC( val->u.s, len + 1 ) )
+ {
+ ft_memcpy( val->u.s, str, len );
+ val->u.s[len] = '\0';
+ }
+ }
break;
case AFM_VALUE_TYPE_FIXED:
@@ -420,8 +420,8 @@
break;
case AFM_VALUE_TYPE_BOOL:
- val->u.b = ( len == 4 &&
- ft_strncmp( str, "true", 4 ) == 0 );
+ val->u.b = FT_BOOL( len == 4 &&
+ !ft_strncmp( str, "true", 4 ) );
break;
case AFM_VALUE_TYPE_INDEX:
@@ -443,7 +443,7 @@
FT_UInt* len )
{
AFM_Stream stream = parser->stream;
- char* key;
+ char* key = 0; /* make stupid compiler happy */
if ( line )
@@ -598,13 +598,14 @@
FT_Error error;
- FT_QNEW_ARRAY( fi->TrackKerns, fi->NumTrackKern );
- if ( error )
+ if ( FT_QNEW_ARRAY( fi->TrackKerns, fi->NumTrackKern ) )
return error;
}
- while ( ( key = afm_parser_next_key( parser, 1, &len ) ) )
+ while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
{
+ AFM_ValueRec shared_vals[5];
+
switch ( afm_tokenize( key, len ) )
{
case AFM_TOKEN_TRACKKERN:
@@ -694,12 +695,11 @@
FT_Error error;
- FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair );
- if ( error )
+ if ( FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair ) )
return error;
}
- while ( ( key = afm_parser_next_key( parser, 1, &len ) ) )
+ while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
{
AFM_Token token = afm_tokenize( key, len );
@@ -710,7 +710,8 @@
case AFM_TOKEN_KPX:
case AFM_TOKEN_KPY:
{
- FT_Int r;
+ FT_Int r;
+ AFM_ValueRec shared_vals[4];
n++;
@@ -775,7 +776,7 @@
FT_UInt len;
- while ( ( key = afm_parser_next_key( parser, 1, &len ) ) )
+ while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
{
switch ( afm_tokenize( key, len ) )
{
@@ -826,7 +827,7 @@
goto Fail;
}
- while ( ( key = afm_parser_next_key( parser, 1, &len ) ) )
+ while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
{
AFM_Token token = afm_tokenize( key, len );
@@ -859,7 +860,7 @@
ft_strncmp( key, "StartFontMetrics", 16 ) != 0 )
return PSaux_Err_Unknown_File_Format;
- while ( ( key = afm_parser_next_key( parser, 1, &len ) ) )
+ while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
{
switch ( afm_tokenize( key, len ) )
{
@@ -876,11 +877,15 @@
break;
case AFM_TOKEN_ISCIDFONT:
- shared_vals[0].type = AFM_VALUE_TYPE_BOOL;
- if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
- goto Fail;
+ {
+ AFM_ValueRec shared_vals[1];
+
+ shared_vals[0].type = AFM_VALUE_TYPE_BOOL;
+ if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
+ goto Fail;
- fi->IsCIDFont = shared_vals[0].u.b;
+ fi->IsCIDFont = shared_vals[0].u.b;
+ }
break;
case AFM_TOKEN_STARTCHARMETRICS:
--- a/src/psaux/afmparse.h
+++ b/src/psaux/afmparse.h
@@ -66,12 +66,12 @@
} AFM_ValueRec, *AFM_Value;
+#define AFM_MAX_ARGUMENTS 5
FT_LOCAL( FT_Int )
afm_parser_read_vals( AFM_Parser parser,
AFM_Value vals,
FT_Int n );
-
/* read the next key from the next line or column */
FT_LOCAL( char* )
--- a/src/psaux/psconv.c
+++ b/src/psaux/psconv.c
@@ -20,6 +20,7 @@
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_DEBUG_H
+#include "psconv.h"
#include "psobjs.h"
#include "psauxerr.h"
@@ -85,7 +86,7 @@
if ( *p == '-' || *p == '+' )
{
- sign = ( *p == '-' );
+ sign = FT_BOOL( *p == '-' );
p++;
if ( p == limit )
@@ -156,7 +157,7 @@
if ( *p == '-' || *p == '+' )
{
- sign = ( *p == '-' );
+ sign = FT_BOOL( *p == '-' );
p++;
if ( p == limit )
@@ -351,9 +352,12 @@
break;
if ( r % 2 )
- *buffer++ += c;
+ {
+ *buffer = (FT_Byte)(*buffer + c);
+ buffer++;
+ }
else
- *buffer = c << 4;
+ *buffer = (FT_Byte)(c << 4);
r++;
}
@@ -378,7 +382,7 @@
for ( r = 0, p = *cursor; r < n && p < limit; r++, p++ )
{
- FT_Byte b = ( *p ^ ( s >> 8 ) );
+ FT_Byte b = (FT_Byte)( *p ^ ( s >> 8 ) );
s = (FT_UShort)( ( *p + s ) * 52845U + 22719 );
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -51,11 +51,12 @@
FT_String* string;
FT_UInt len, code, n;
FT_Byte* read = (FT_Byte*)entry->string;
+ FT_Error error;
len = (FT_UInt)entry->stringLength / 2;
- if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
+ if ( FT_NEW_ARRAY( string, len + 1 ) )
return NULL;
for ( n = 0; n < len; n++ )
@@ -81,11 +82,12 @@
FT_String* string;
FT_UInt len, code, n;
FT_Byte* read = (FT_Byte*)entry->string;
+ FT_Error error;
len = (FT_UInt)entry->stringLength / 4;
- if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
+ if ( FT_NEW_ARRAY( string, len + 1 ) )
return NULL;
for ( n = 0; n < len; n++ )
@@ -111,11 +113,12 @@
FT_String* string;
FT_UInt len, code, n;
FT_Byte* read = (FT_Byte*)entry->string;
+ FT_Error error;
len = (FT_UInt)entry->stringLength;
- if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
+ if ( FT_NEW_ARRAY( string, len + 1 ) )
return NULL;
for ( n = 0; n < len; n++ )
--- a/src/sfnt/ttsbit0.c
+++ b/src/sfnt/ttsbit0.c
@@ -172,9 +172,9 @@
bsize->y_ppem = (FT_Pos)(y_ppem << 6);
/* XXX: Is this correct? */
- bsize->height = ascender - descender;
- bsize->width = (FT_Short)( avgwidth * y_ppem + em_size / 2 ) /
- em_size;
+ bsize->height = (FT_Short)(ascender - descender);
+ bsize->width = (FT_Short)( ( avgwidth * y_ppem + em_size / 2 ) /
+ em_size );
/* assume 72dpi */
bsize->size = bsize->y_ppem;
@@ -232,9 +232,9 @@
bsize = ( (FT_Face)face )->available_sizes + strike_index;
strike = face->sbit_table + 8 + strike_index * 48;
- metrics->x_ppem = bsize->x_ppem >> 6;
- metrics->y_ppem = bsize->y_ppem >> 6;
- metrics->height = bsize->height << 6;
+ metrics->x_ppem = (FT_UShort)(bsize->x_ppem >> 6);
+ metrics->y_ppem = (FT_UShort)(bsize->y_ppem >> 6);
+ metrics->height = (FT_UShort)(bsize->height << 6);
metrics->ascender = (FT_Char)strike[16] << 6; /* hori.ascender */
metrics->descender = (FT_Char)strike[17] << 6; /* hori.descender */
--- a/src/tools/apinames.c
+++ b/src/tools/apinames.c
@@ -1,6 +1,6 @@
/*
* This little program is used to parse the FreeType headers and
- * find the declaration of all public API. This is easy, because
+ * find the declaration of all public APIs. This is easy, because
* they all look like the following:
*
* FT_EXPORT( return_type )
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#define PROGRAM_NAME "apinames"
#define PROGRAM_VERSION "0.1"
@@ -75,7 +76,7 @@
{
nm = the_names + nn;
- if ( nm->hash == h &&
+ if ( (int)nm->hash == h &&
memcmp( name, nm->name, len ) == 0 &&
nm->name[len] == 0 )
return;
@@ -164,7 +165,7 @@
if ( dot != NULL )
{
int len = (dot - dll_name);
- if ( len > sizeof(temp)-1 )
+ if ( len > (int)(sizeof(temp)-1) )
len = sizeof(temp)-1;
memcpy( temp, dll_name, len );
@@ -257,7 +258,6 @@
case STATE_TYPE:
{
char* name = p;
- size_t func_len;
while ( isalnum(*p) || *p == '_' )
p++;
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -20,7 +20,7 @@
#include "t1afm.h"
#include "t1errors.h"
#include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_TYPE1_TYPES_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
/*************************************************************************/
@@ -232,12 +232,14 @@
FT_Error error = T1_Err_Unknown_File_Format;
- if ( FT_FRAME_ENTER( stream->size ) )
+ if ( FT_NEW( fi ) )
return error;
- FT_NEW( fi );
- if ( error )
+ if ( FT_FRAME_ENTER( stream->size ) )
+ {
+ FT_FREE( fi );
return error;
+ }
psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux;
if ( psaux && psaux->afm_parser_funcs )
--- a/src/type1/t1afm.h
+++ b/src/type1/t1afm.h
@@ -21,7 +21,7 @@
#include <ft2build.h>
#include "t1objs.h"
-
+#include FT_INTERNAL_TYPE1_TYPES_H
FT_BEGIN_HEADER