Fix compilation errors and (some) warnings for clang++.

* src/autofit/afmodule.c (AF_GlyphHintsRec): Make it static.

* src/cache/ftcache.c (FTC_Cache_NewNode), src/cache/ftcsbits.c
(ftc_snode_compare): Remove semicolon.

* src/cff/cffparse.c (cff_parser_run): Add `break` statement.

* src/cid/cidload.c (cid_hex_to_binary): Add cast.

* src/sdf/ftbsdf.c (CHECK_NEIGHBOR): Use `do {} while(0)` loop.
(bsdf_init_distance_map, finalize_sdf, bsdf_raster_render): Add
casts.
* src/sdf/ftsdf.c (sdf_generate_bounding_box,
sdf_generate_with_overlaps): Ditto.
* src/sdf/ftsdfcommon.h (square_root): Ditto.
* src/sdf/ftsdfrend.c (sdf_property_get, ft_sdf_render,
ft_bsdf_render): Ditto.

* src/sfnt/ttcolr.c (find_base_glyph_record,
find_base_glyph_v1_record): Fix variable signedness.
(read_color_line): Add cast.
(read_paint): Add casts.
Fix signedness issue.
(tt_face_get_colorline_stops) Fix signedness issues.

* src/sfnt/ttpost.c (load_format_20): Add casts.

* src/truetype/ttsubpix.c (TWEAK_RULES, TWEAK_RULES_EXCEPTIONS):
Remove final semicolons.
This commit is contained in:
Werner Lemberg 2021-05-29 09:50:29 +02:00
parent 2bfdc161fb
commit a50c39aa8e
13 changed files with 126 additions and 84 deletions

View File

@ -1,3 +1,37 @@
2021-05-29 Werner Lemberg <wl@gnu.org>
Fix compilation errors and (some) warnings for clang++.
* src/autofit/afmodule.c (AF_GlyphHintsRec): Make it static.
* src/cache/ftcache.c (FTC_Cache_NewNode), src/cache/ftcsbits.c
(ftc_snode_compare): Remove semicolon.
* src/cff/cffparse.c (cff_parser_run): Add `break` statement.
* src/cid/cidload.c (cid_hex_to_binary): Add cast.
* src/sdf/ftbsdf.c (CHECK_NEIGHBOR): Use `do {} while(0)` loop.
(bsdf_init_distance_map, finalize_sdf, bsdf_raster_render): Add
casts.
* src/sdf/ftsdf.c (sdf_generate_bounding_box,
sdf_generate_with_overlaps): Ditto.
* src/sdf/ftsdfcommon.h (square_root): Ditto.
* src/sdf/ftsdfrend.c (sdf_property_get, ft_sdf_render,
ft_bsdf_render): Ditto.
* src/sfnt/ttcolr.c (find_base_glyph_record,
find_base_glyph_v1_record): Fix variable signedness.
(read_color_line): Add cast.
(read_paint): Add casts.
Fix signedness issue.
(tt_face_get_colorline_stops) Fix signedness issues.
* src/sfnt/ttpost.c (load_format_20): Add casts.
* src/truetype/ttsubpix.c (TWEAK_RULES, TWEAK_RULES_EXCEPTIONS):
Remove final semicolons.
2021-05-29 Werner Lemberg <wl@gnu.org>
[build] Allow overriding of `ANSIFLAGS` for GNU make build.

View File

@ -48,7 +48,7 @@
int _af_debug_disable_blue_hints;
/* we use a global object instead of a local one for debugging */
AF_GlyphHintsRec _af_debug_hints_rec[1];
static AF_GlyphHintsRec _af_debug_hints_rec[1];
void* _af_debug_hints = _af_debug_hints_rec;
#endif

View File

@ -459,7 +459,7 @@
{
error = cache->clazz.node_new( &node, query, cache );
}
FTC_CACHE_TRYLOOP_END( NULL );
FTC_CACHE_TRYLOOP_END( NULL )
if ( error )
node = NULL;

View File

@ -395,7 +395,7 @@
{
error = ftc_snode_load( snode, cache->manager, gindex, &size );
}
FTC_CACHE_TRYLOOP_END( list_changed );
FTC_CACHE_TRYLOOP_END( list_changed )
ftcsnode->ref_count--; /* unlock the node */

View File

@ -1516,6 +1516,7 @@
case cff_kind_fixed_thousand:
FT_TRACE4(( " %f\n", (double)val / 65536 / 1000 ));
break;
default:
; /* never reached */

View File

@ -758,7 +758,7 @@
error = FT_Err_Ok;
Exit:
*data_written = d - data;
*data_written = FT_ULong( d - data );
return error;
}

View File

@ -289,19 +289,22 @@
#undef CHECK_NEIGHBOR
#endif
#define CHECK_NEIGHBOR( x_offset, y_offset ) \
if ( x + x_offset >= 0 && x + x_offset < w && \
y + y_offset >= 0 && y + y_offset < r ) \
{ \
num_neighbors++; \
\
to_check = dm + y_offset * w + x_offset; \
if ( to_check->alpha == 0 ) \
{ \
is_edge = 1; \
goto Done; \
} \
}
#define CHECK_NEIGHBOR( x_offset, y_offset ) \
do \
{ \
if ( x + x_offset >= 0 && x + x_offset < w && \
y + y_offset >= 0 && y + y_offset < r ) \
{ \
num_neighbors++; \
\
to_check = dm + y_offset * w + x_offset; \
if ( to_check->alpha == 0 ) \
{ \
is_edge = 1; \
goto Done; \
} \
} \
} while ( 0 )
static FT_Bool
bsdf_is_edge( ED* dm, /* distance map */
@ -693,8 +696,8 @@
/* Calculate the width and row differences */
/* between target and source. */
x_diff = worker->width - source->width;
y_diff = worker->rows - source->rows;
x_diff = worker->width - (int)source->width;
y_diff = worker->rows - (int)source->rows;
x_diff /= 2;
y_diff /= 2;
@ -716,8 +719,8 @@
{
FT_Int t_width = worker->width;
FT_Int t_rows = worker->rows;
FT_Int s_width = source->width;
FT_Int s_rows = source->rows;
FT_Int s_width = (int)source->width;
FT_Int s_rows = (int)source->rows;
for ( t_j = 0; t_j < t_rows; t_j++ )
@ -750,7 +753,7 @@
mod = 7 - s_i % 8;
pixel = s[div];
byte = 1 << mod;
byte = (FT_Byte)( 1 << mod );
t[t_index].alpha = pixel & byte ? 255 : 0;
@ -764,8 +767,8 @@
{
FT_Int t_width = worker->width;
FT_Int t_rows = worker->rows;
FT_Int s_width = source->width;
FT_Int s_rows = source->rows;
FT_Int s_width = (int)source->width;
FT_Int s_rows = (int)source->rows;
/* loop over all pixels and assign pixel values from source */
@ -1103,8 +1106,8 @@
goto Exit;
}
w = target->width;
r = target->rows;
w = (int)target->width;
r = (int)target->rows;
t_buffer = (FT_6D10*)target->buffer;
if ( w != worker->width ||
@ -1222,8 +1225,8 @@
FT_Error error = FT_Err_Ok;
FT_Memory memory = NULL;
const FT_Bitmap* source = NULL;
const FT_Bitmap* target = NULL;
const FT_Bitmap* source = NULL;
const FT_Bitmap* target = NULL;
BSDF_TRaster* bsdf_raster = (BSDF_TRaster*)raster;
BSDF_Worker worker;
@ -1247,8 +1250,8 @@
goto Exit;
}
source = sdf_params->root.source;
target = sdf_params->root.target;
source = (const FT_Bitmap*)sdf_params->root.source;
target = (const FT_Bitmap*)sdf_params->root.target;
/* check source and target bitmap */
if ( !source || !target )
@ -1298,8 +1301,8 @@
target->width * sizeof ( *worker.distance_map ) ) )
goto Exit;
worker.width = target->width;
worker.rows = target->rows;
worker.width = (int)target->width;
worker.rows = (int)target->rows;
worker.params = *sdf_params;
FT_CALL( bsdf_init_distance_map( source, &worker ) );
@ -1309,7 +1312,7 @@
FT_TRACE0(( "bsdf_raster_render: Total memory used = %ld\n",
worker.width * worker.rows *
sizeof ( *worker.distance_map ) ));
(long)sizeof ( *worker.distance_map ) ));
Exit:
if ( worker.distance_map )

View File

@ -3222,18 +3222,19 @@
goto Exit;
}
if ( FT_ALLOC( dists,
bitmap->width * bitmap->rows * sizeof ( *dists ) ) )
goto Exit;
contours = shape->contours;
width = (FT_Int)bitmap->width;
rows = (FT_Int)bitmap->rows;
buffer = (FT_Short*)bitmap->buffer;
if ( FT_ALLOC( dists, width * rows * sizeof ( *dists ) ) )
goto Exit;
if ( USE_SQUARED_DISTANCES )
sp_sq = FT_INT_16D16( spread * spread );
sp_sq = (FT_Int)FT_INT_16D16( spread * spread );
else
sp_sq = FT_INT_16D16( spread );
sp_sq = (FT_Int)FT_INT_16D16( spread );
if ( width == 0 || rows == 0 )
{
@ -3307,9 +3308,9 @@
dist.distance = square_root( dist.distance );
if ( internal_params.flip_y )
index = y * width + x;
index = FT_UInt( y * width + x );
else
index = ( rows - y - 1 ) * width + x;
index = FT_UInt( ( rows - y - 1 ) * width + x );
/* check whether the pixel is set or not */
if ( dists[index].sign == 0 )
@ -3341,7 +3342,7 @@
for ( i = 0; i < width; i++ )
{
index = j * width + i;
index = (FT_UInt)( j * width + i );
/* if the pixel is not set */
/* its shortest distance is more than `spread` */
@ -3527,11 +3528,13 @@
}
/* allocate the bitmaps to generate SDF for separate contours */
if ( FT_ALLOC( bitmaps, num_contours * sizeof ( *bitmaps ) ) )
if ( FT_ALLOC( bitmaps,
(FT_UInt)num_contours * sizeof ( *bitmaps ) ) )
goto Exit;
/* allocate array to hold orientation for all contours */
if ( FT_ALLOC( orientations, num_contours * sizeof ( *orientations ) ) )
if ( FT_ALLOC( orientations,
(FT_UInt)num_contours * sizeof ( *orientations ) ) )
goto Exit;
/* Disable `flip_sign` to avoid extra complication */
@ -3554,7 +3557,8 @@
bitmaps[i].pixel_mode = bitmap->pixel_mode;
/* allocate memory for the buffer */
if ( FT_ALLOC( bitmaps[i].buffer, bitmap->rows * bitmap->pitch ) )
if ( FT_ALLOC( bitmaps[i].buffer,
bitmap->rows * (FT_UInt)bitmap->pitch ) )
goto Exit;
/* determine the orientation */

View File

@ -139,7 +139,7 @@ FT_BEGIN_HEADER
FT_ULong t, q, b, r;
r = val;
r = (FT_ULong)val;
b = 0x40000000L;
q = 0;
@ -159,7 +159,7 @@ FT_BEGIN_HEADER
q >>= 8;
return q;
return (FT_16D16)q;
}

View File

@ -142,7 +142,7 @@
if ( ft_strcmp( property_name, "spread" ) == 0 )
{
FT_Int* val = (FT_Int*)value;
FT_UInt* val = (FT_UInt*)value;
*val = render->spread;
@ -314,7 +314,7 @@
/* ignore the pitch, pixel mode and set custom */
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY16;
bitmap->pitch = bitmap->width * 2;
bitmap->pitch = (int)( bitmap->width * 2 );
bitmap->num_grays = 65535;
/* allocate new buffer */
@ -525,7 +525,7 @@
/* set up the target bitmap */
target.pixel_mode = FT_PIXEL_MODE_GRAY16;
target.pitch = target.width * 2;
target.pitch = (int)( target.width * 2 );
target.num_grays = 65535;
if ( FT_ALLOC_MULT( target.buffer, target.rows, target.pitch ) )

View File

@ -228,17 +228,17 @@
static FT_Bool
find_base_glyph_record( FT_Byte* base_glyph_begin,
FT_Int num_base_glyph,
FT_UInt num_base_glyph,
FT_UInt glyph_id,
BaseGlyphRecord* record )
{
FT_Int min = 0;
FT_Int max = num_base_glyph - 1;
FT_UInt min = 0;
FT_UInt max = num_base_glyph - 1;
while ( min <= max )
{
FT_Int mid = min + ( max - min ) / 2;
FT_UInt mid = min + ( max - min ) / 2;
FT_Byte* p = base_glyph_begin + mid * BASE_GLYPH_SIZE;
FT_UShort gid = FT_NEXT_USHORT( p );
@ -327,7 +327,7 @@
FT_PaintExtend paint_extend;
paint_extend = FT_NEXT_BYTE( p );
paint_extend = (FT_PaintExtend)FT_NEXT_BYTE( p );
if ( paint_extend > FT_COLR_PAINT_EXTEND_REFLECT )
return 0;
@ -392,7 +392,7 @@
p >= ( (FT_Byte*)colr->table + colr->table_size ) )
return 0;
apaint->format = FT_NEXT_BYTE( p );
apaint->format = (FT_PaintFormat)FT_NEXT_BYTE( p );
if ( apaint->format >= FT_COLR_PAINT_FORMAT_MAX )
return 0;
@ -425,8 +425,8 @@
else if ( apaint->format == FT_COLR_PAINTFORMAT_SOLID )
{
apaint->u.solid.color.palette_index = FT_NEXT_USHORT ( p );
apaint->u.solid.color.alpha = FT_NEXT_USHORT ( p );
apaint->u.solid.color.palette_index = FT_NEXT_USHORT( p );
apaint->u.solid.color.alpha = FT_NEXT_SHORT( p );
return 1;
}
@ -454,12 +454,12 @@
&apaint->u.linear_gradient.colorline ) )
return 0;
apaint->u.linear_gradient.p0.x = FT_NEXT_SHORT ( p );
apaint->u.linear_gradient.p0.y = FT_NEXT_SHORT ( p );
apaint->u.linear_gradient.p1.x = FT_NEXT_SHORT ( p );
apaint->u.linear_gradient.p1.y = FT_NEXT_SHORT ( p );
apaint->u.linear_gradient.p2.x = FT_NEXT_SHORT ( p );
apaint->u.linear_gradient.p2.y = FT_NEXT_SHORT ( p );
apaint->u.linear_gradient.p0.x = FT_NEXT_SHORT( p );
apaint->u.linear_gradient.p0.y = FT_NEXT_SHORT( p );
apaint->u.linear_gradient.p1.x = FT_NEXT_SHORT( p );
apaint->u.linear_gradient.p1.y = FT_NEXT_SHORT( p );
apaint->u.linear_gradient.p2.x = FT_NEXT_SHORT( p );
apaint->u.linear_gradient.p2.y = FT_NEXT_SHORT( p );
return 1;
}
@ -470,15 +470,15 @@
&apaint->u.radial_gradient.colorline ) )
return 0;
apaint->u.radial_gradient.c0.x = FT_NEXT_SHORT ( p );
apaint->u.radial_gradient.c0.y = FT_NEXT_SHORT ( p );
apaint->u.radial_gradient.c0.x = FT_NEXT_SHORT( p );
apaint->u.radial_gradient.c0.y = FT_NEXT_SHORT( p );
apaint->u.radial_gradient.r0 = FT_NEXT_USHORT ( p );
apaint->u.radial_gradient.r0 = FT_NEXT_USHORT( p );
apaint->u.radial_gradient.c1.x = FT_NEXT_SHORT ( p );
apaint->u.radial_gradient.c1.y = FT_NEXT_SHORT ( p );
apaint->u.radial_gradient.c1.x = FT_NEXT_SHORT( p );
apaint->u.radial_gradient.c1.y = FT_NEXT_SHORT( p );
apaint->u.radial_gradient.r1 = FT_NEXT_USHORT ( p );
apaint->u.radial_gradient.r1 = FT_NEXT_USHORT( p );
return 1;
}
@ -489,8 +489,8 @@
&apaint->u.sweep_gradient.colorline ) )
return 0;
apaint->u.sweep_gradient.center.x = FT_NEXT_SHORT ( p );
apaint->u.sweep_gradient.center.y = FT_NEXT_SHORT ( p );
apaint->u.sweep_gradient.center.x = FT_NEXT_SHORT( p );
apaint->u.sweep_gradient.center.y = FT_NEXT_SHORT( p );
apaint->u.sweep_gradient.start_angle = FT_NEXT_LONG( p );
apaint->u.sweep_gradient.end_angle = FT_NEXT_LONG( p );
@ -572,7 +572,7 @@
if ( composite_mode >= FT_COLR_COMPOSITE_MAX )
return 0;
apaint->u.composite.composite_mode = composite_mode;
apaint->u.composite.composite_mode = (FT_Composite_Mode)composite_mode;
if ( !get_child_table_pointer( colr, paint_base, &p, &child_table_p ) )
return 0;
@ -591,17 +591,17 @@
static FT_Bool
find_base_glyph_v1_record ( FT_Byte * base_glyph_begin,
FT_Int num_base_glyph,
FT_UInt num_base_glyph,
FT_UInt glyph_id,
BaseGlyphV1Record *record )
{
FT_Int min = 0;
FT_Int max = num_base_glyph - 1;
FT_UInt min = 0;
FT_UInt max = num_base_glyph - 1;
while ( min <= max )
{
FT_Int mid = min + ( max - min ) / 2;
FT_UInt mid = min + ( max - min ) / 2;
/*
* `base_glyph_begin` is the beginning of `BaseGlyphV1List`;
@ -763,11 +763,11 @@
/* Iterator points at first `ColorStop` of `ColorLine`. */
p = iterator->p;
color_stop->stop_offset = FT_NEXT_USHORT ( p );
color_stop->stop_offset = FT_NEXT_SHORT( p );
color_stop->color.palette_index = FT_NEXT_USHORT ( p );
color_stop->color.palette_index = FT_NEXT_USHORT( p );
color_stop->color.alpha = FT_NEXT_USHORT ( p );
color_stop->color.alpha = FT_NEXT_SHORT( p );
iterator->p = p;
iterator->current_color_stop++;

View File

@ -180,8 +180,8 @@
/* There already exist fonts which have more than 32768 glyph names */
/* in this table, so the test for this threshold has been dropped. */
if ( num_glyphs > face->max_profile.numGlyphs ||
num_glyphs * 2UL > post_len - 2 )
if ( num_glyphs > face->max_profile.numGlyphs ||
(FT_ULong)num_glyphs * 2UL > post_len - 2 )
{
error = FT_THROW( Invalid_File_Format );
goto Exit;
@ -231,7 +231,7 @@
FT_ULong p;
post_len -= num_glyphs * 2UL + 2;
post_len -= (FT_ULong)num_glyphs * 2UL + 2;
if ( FT_QALLOC( strings, post_len + 1 ) ||
FT_STREAM_READ( strings, post_len ) ||

View File

@ -891,12 +891,12 @@
#define TWEAK_RULES( x ) \
if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
x##_Rules, x##_RULES_SIZE ) ) \
loader->exec->sph_tweak_flags |= SPH_TWEAK_##x;
loader->exec->sph_tweak_flags |= SPH_TWEAK_##x
#define TWEAK_RULES_EXCEPTIONS( x ) \
if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
x##_Rules_Exceptions, x##_RULES_EXCEPTIONS_SIZE ) ) \
loader->exec->sph_tweak_flags &= ~SPH_TWEAK_##x;
loader->exec->sph_tweak_flags &= ~SPH_TWEAK_##x
FT_LOCAL_DEF( void )