[truetype] Various signedness fixes.
* include/internal/ftgloadr.h, src/truetype/ttpload.c: Apply. * src/truetype/ttgload.c: Apply. (TT_Get_VMetrics): Protect against invalid ascenders and descenders while constructing advance height.
This commit is contained in:
parent
76abc75c26
commit
0a33a3984f
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2015-02-17 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
|
[truetype] Various signedness fixes.
|
||||||
|
|
||||||
|
* include/internal/ftgloadr.h, src/truetype/ttpload.c: Apply.
|
||||||
|
|
||||||
|
* src/truetype/ttgload.c: Apply.
|
||||||
|
(TT_Get_VMetrics): Protect against invalid ascenders and descenders
|
||||||
|
while constructing advance height.
|
||||||
|
|
||||||
2015-02-16 Werner Lemberg <wl@gnu.org>
|
2015-02-16 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
[base] Finish compiler warning fixes for signedness issues.
|
[base] Finish compiler warning fixes for signedness issues.
|
||||||
|
|
|
@ -123,21 +123,23 @@ FT_BEGIN_HEADER
|
||||||
|
|
||||||
#define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \
|
#define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \
|
||||||
( (_count) == 0 || \
|
( (_count) == 0 || \
|
||||||
( (_loader)->base.outline.n_points + \
|
( (FT_UInt)(_loader)->base.outline.n_points + \
|
||||||
(_loader)->current.outline.n_points + \
|
(FT_UInt)(_loader)->current.outline.n_points + \
|
||||||
(unsigned long)(_count) ) <= (_loader)->max_points )
|
(FT_UInt)(_count) ) <= (_loader)->max_points )
|
||||||
|
|
||||||
#define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \
|
#define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \
|
||||||
( (_count) == 0 || \
|
( (_count) == 0 || \
|
||||||
( (_loader)->base.outline.n_contours + \
|
( (FT_UInt)(_loader)->base.outline.n_contours + \
|
||||||
(_loader)->current.outline.n_contours + \
|
(FT_UInt)(_loader)->current.outline.n_contours + \
|
||||||
(unsigned long)(_count)) <= (_loader)->max_contours )
|
(FT_UInt)(_count) ) <= (_loader)->max_contours )
|
||||||
|
|
||||||
#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points, _contours ) \
|
#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points, _contours ) \
|
||||||
( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \
|
( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \
|
||||||
FT_GLYPHLOADER_CHECK_C( _loader, _contours ) ) \
|
FT_GLYPHLOADER_CHECK_C( _loader, _contours ) ) \
|
||||||
? 0 \
|
? 0 \
|
||||||
: FT_GlyphLoader_CheckPoints( (_loader), (_points), (_contours) ) )
|
: FT_GlyphLoader_CheckPoints( (_loader), \
|
||||||
|
(FT_UInt)(_points), \
|
||||||
|
(FT_UInt)(_contours) ) )
|
||||||
|
|
||||||
|
|
||||||
/* check that there is enough space to add `n_subs' sub-glyphs to */
|
/* check that there is enough space to add `n_subs' sub-glyphs to */
|
||||||
|
|
|
@ -100,13 +100,15 @@
|
||||||
else if ( face->os2.version != 0xFFFFU )
|
else if ( face->os2.version != 0xFFFFU )
|
||||||
{
|
{
|
||||||
*tsb = (FT_Short)( face->os2.sTypoAscender - yMax );
|
*tsb = (FT_Short)( face->os2.sTypoAscender - yMax );
|
||||||
*ah = face->os2.sTypoAscender - face->os2.sTypoDescender;
|
*ah = (FT_UShort)FT_ABS( face->os2.sTypoAscender -
|
||||||
|
face->os2.sTypoDescender );
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*tsb = (FT_Short)( face->horizontal.Ascender - yMax );
|
*tsb = (FT_Short)( face->horizontal.Ascender - yMax );
|
||||||
*ah = face->horizontal.Ascender - face->horizontal.Descender;
|
*ah = (FT_UShort)FT_ABS( face->horizontal.Ascender -
|
||||||
|
face->horizontal.Descender );
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_TRACE5(( " advance height (font units): %d\n", *ah ));
|
FT_TRACE5(( " advance height (font units): %d\n", *ah ));
|
||||||
|
@ -555,8 +557,8 @@
|
||||||
*flag = (FT_Byte)( f & FT_CURVE_TAG_ON );
|
*flag = (FT_Byte)( f & FT_CURVE_TAG_ON );
|
||||||
}
|
}
|
||||||
|
|
||||||
outline->n_points = (FT_UShort)n_points;
|
outline->n_points = (FT_Short)n_points;
|
||||||
outline->n_contours = (FT_Short) n_contours;
|
outline->n_contours = (FT_Short)n_contours;
|
||||||
|
|
||||||
load->cursor = p;
|
load->cursor = p;
|
||||||
|
|
||||||
|
@ -707,9 +709,10 @@
|
||||||
FT_UInt start_point,
|
FT_UInt start_point,
|
||||||
FT_UInt start_contour )
|
FT_UInt start_contour )
|
||||||
{
|
{
|
||||||
zone->n_points = (FT_UShort)( load->outline.n_points - start_point );
|
zone->n_points = (FT_UShort)load->outline.n_points -
|
||||||
zone->n_contours = (FT_Short) ( load->outline.n_contours -
|
(FT_UShort)start_point;
|
||||||
start_contour );
|
zone->n_contours = load->outline.n_contours -
|
||||||
|
(FT_Short)start_contour;
|
||||||
zone->org = load->extra_points + start_point;
|
zone->org = load->extra_points + start_point;
|
||||||
zone->cur = load->outline.points + start_point;
|
zone->cur = load->outline.points + start_point;
|
||||||
zone->orus = load->extra_points2 + start_point;
|
zone->orus = load->extra_points2 + start_point;
|
||||||
|
@ -740,7 +743,7 @@
|
||||||
TT_GlyphZone zone = &loader->zone;
|
TT_GlyphZone zone = &loader->zone;
|
||||||
|
|
||||||
#ifdef TT_USE_BYTECODE_INTERPRETER
|
#ifdef TT_USE_BYTECODE_INTERPRETER
|
||||||
FT_UInt n_ins;
|
FT_Long n_ins;
|
||||||
#else
|
#else
|
||||||
FT_UNUSED( is_composite );
|
FT_UNUSED( is_composite );
|
||||||
#endif
|
#endif
|
||||||
|
@ -753,7 +756,7 @@
|
||||||
FT_TRACE1(( " (0x%lx byte) is truncated\n",
|
FT_TRACE1(( " (0x%lx byte) is truncated\n",
|
||||||
loader->glyph->control_len ));
|
loader->glyph->control_len ));
|
||||||
}
|
}
|
||||||
n_ins = (FT_UInt)( loader->glyph->control_len );
|
n_ins = loader->glyph->control_len;
|
||||||
|
|
||||||
/* save original point position in org */
|
/* save original point position in org */
|
||||||
if ( n_ins > 0 )
|
if ( n_ins > 0 )
|
||||||
|
@ -887,7 +890,7 @@
|
||||||
error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face),
|
error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face),
|
||||||
loader->glyph_index,
|
loader->glyph_index,
|
||||||
&deltas,
|
&deltas,
|
||||||
n_points );
|
(FT_UInt)n_points );
|
||||||
if ( error )
|
if ( error )
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
@ -916,9 +919,9 @@
|
||||||
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
|
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
|
||||||
|
|
||||||
FT_String* family = face->root.family_name;
|
FT_String* family = face->root.family_name;
|
||||||
FT_Int ppem = loader->size->metrics.x_ppem;
|
FT_UInt ppem = loader->size->metrics.x_ppem;
|
||||||
FT_String* style = face->root.style_name;
|
FT_String* style = face->root.style_name;
|
||||||
FT_Int x_scale_factor = 1000;
|
FT_UInt x_scale_factor = 1000;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FT_Vector* vec = outline->points;
|
FT_Vector* vec = outline->points;
|
||||||
|
@ -946,7 +949,7 @@
|
||||||
x_scale_factor != 1000 )
|
x_scale_factor != 1000 )
|
||||||
{
|
{
|
||||||
x_scale = FT_MulDiv( ((TT_Size)loader->size)->metrics.x_scale,
|
x_scale = FT_MulDiv( ((TT_Size)loader->size)->metrics.x_scale,
|
||||||
x_scale_factor, 1000 );
|
(FT_Long)x_scale_factor, 1000 );
|
||||||
y_scale = ((TT_Size)loader->size)->metrics.y_scale;
|
y_scale = ((TT_Size)loader->size)->metrics.y_scale;
|
||||||
|
|
||||||
/* compensate for any scaling by de/emboldening; */
|
/* compensate for any scaling by de/emboldening; */
|
||||||
|
@ -1017,7 +1020,7 @@
|
||||||
{
|
{
|
||||||
FT_GlyphLoader gloader = loader->gloader;
|
FT_GlyphLoader gloader = loader->gloader;
|
||||||
FT_Vector* base_vec = gloader->base.outline.points;
|
FT_Vector* base_vec = gloader->base.outline.points;
|
||||||
FT_UInt num_points = gloader->base.outline.n_points;
|
FT_UInt num_points = (FT_UInt)gloader->base.outline.n_points;
|
||||||
FT_Bool have_scale;
|
FT_Bool have_scale;
|
||||||
FT_Pos x, y;
|
FT_Pos x, y;
|
||||||
|
|
||||||
|
@ -1039,8 +1042,8 @@
|
||||||
/* get offset */
|
/* get offset */
|
||||||
if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
|
if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
|
||||||
{
|
{
|
||||||
FT_UInt k = subglyph->arg1;
|
FT_UInt k = (FT_UInt)subglyph->arg1;
|
||||||
FT_UInt l = subglyph->arg2;
|
FT_UInt l = (FT_UInt)subglyph->arg2;
|
||||||
FT_Vector* p1;
|
FT_Vector* p1;
|
||||||
FT_Vector* p2;
|
FT_Vector* p2;
|
||||||
|
|
||||||
|
@ -1470,7 +1473,8 @@
|
||||||
|
|
||||||
FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) );
|
FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) );
|
||||||
FT_Stream_OpenMemory( &inc_stream,
|
FT_Stream_OpenMemory( &inc_stream,
|
||||||
glyph_data.pointer, glyph_data.length );
|
glyph_data.pointer,
|
||||||
|
(FT_ULong)glyph_data.length );
|
||||||
|
|
||||||
loader->stream = &inc_stream;
|
loader->stream = &inc_stream;
|
||||||
}
|
}
|
||||||
|
@ -1498,7 +1502,7 @@
|
||||||
|
|
||||||
error = face->access_glyph_frame( loader, glyph_index,
|
error = face->access_glyph_frame( loader, glyph_index,
|
||||||
loader->glyf_offset + offset,
|
loader->glyf_offset + offset,
|
||||||
loader->byte_len );
|
(FT_UInt)loader->byte_len );
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
|
@ -1631,8 +1635,8 @@
|
||||||
FT_ULong ins_pos; /* position of composite instructions, if any */
|
FT_ULong ins_pos; /* position of composite instructions, if any */
|
||||||
|
|
||||||
|
|
||||||
start_point = gloader->base.outline.n_points;
|
start_point = (FT_UInt)gloader->base.outline.n_points;
|
||||||
start_contour = gloader->base.outline.n_contours;
|
start_contour = (FT_UInt)gloader->base.outline.n_contours;
|
||||||
|
|
||||||
/* for each subglyph, read composite header */
|
/* for each subglyph, read composite header */
|
||||||
error = face->read_composite_glyph( loader );
|
error = face->read_composite_glyph( loader );
|
||||||
|
@ -1650,7 +1654,7 @@
|
||||||
|
|
||||||
if ( face->doblend )
|
if ( face->doblend )
|
||||||
{
|
{
|
||||||
FT_Int i, limit;
|
FT_UInt i, limit;
|
||||||
FT_SubGlyph subglyph;
|
FT_SubGlyph subglyph;
|
||||||
FT_Memory memory = face->root.memory;
|
FT_Memory memory = face->root.memory;
|
||||||
|
|
||||||
|
@ -1755,10 +1759,12 @@
|
||||||
pp[2] = loader->pp3;
|
pp[2] = loader->pp3;
|
||||||
pp[3] = loader->pp4;
|
pp[3] = loader->pp4;
|
||||||
|
|
||||||
num_base_points = gloader->base.outline.n_points;
|
num_base_points = (FT_UInt)gloader->base.outline.n_points;
|
||||||
|
|
||||||
error = load_truetype_glyph( loader, subglyph->index,
|
error = load_truetype_glyph( loader,
|
||||||
recurse_count + 1, FALSE );
|
(FT_UInt)subglyph->index,
|
||||||
|
recurse_count + 1,
|
||||||
|
FALSE );
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
|
@ -1774,7 +1780,7 @@
|
||||||
loader->pp4 = pp[3];
|
loader->pp4 = pp[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
num_points = gloader->base.outline.n_points;
|
num_points = (FT_UInt)gloader->base.outline.n_points;
|
||||||
|
|
||||||
if ( num_points == num_base_points )
|
if ( num_points == num_base_points )
|
||||||
continue;
|
continue;
|
||||||
|
@ -2037,7 +2043,7 @@
|
||||||
error = sfnt->load_sbit_image( face,
|
error = sfnt->load_sbit_image( face,
|
||||||
size->strike_index,
|
size->strike_index,
|
||||||
glyph_index,
|
glyph_index,
|
||||||
(FT_Int)load_flags,
|
(FT_UInt)load_flags,
|
||||||
stream,
|
stream,
|
||||||
&glyph->bitmap,
|
&glyph->bitmap,
|
||||||
&metrics );
|
&metrics );
|
||||||
|
@ -2305,7 +2311,7 @@
|
||||||
loader->gloader = gloader;
|
loader->gloader = gloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
loader->load_flags = load_flags;
|
loader->load_flags = (FT_ULong)load_flags;
|
||||||
|
|
||||||
loader->face = (FT_Face)face;
|
loader->face = (FT_Face)face;
|
||||||
loader->size = (FT_Size)size;
|
loader->size = (FT_Size)size;
|
||||||
|
|
|
@ -118,8 +118,8 @@
|
||||||
/* we only handle the case where `maxp' gives a larger value */
|
/* we only handle the case where `maxp' gives a larger value */
|
||||||
if ( face->num_locations <= (FT_ULong)face->root.num_glyphs )
|
if ( face->num_locations <= (FT_ULong)face->root.num_glyphs )
|
||||||
{
|
{
|
||||||
FT_Long new_loca_len =
|
FT_ULong new_loca_len =
|
||||||
( (FT_Long)( face->root.num_glyphs ) + 1 ) << shift;
|
( (FT_ULong)face->root.num_glyphs + 1 ) << shift;
|
||||||
|
|
||||||
TT_Table entry = face->dir_tables;
|
TT_Table entry = face->dir_tables;
|
||||||
TT_Table limit = entry + face->num_tables;
|
TT_Table limit = entry + face->num_tables;
|
||||||
|
@ -131,7 +131,7 @@
|
||||||
/* compute the distance to next table in font file */
|
/* compute the distance to next table in font file */
|
||||||
for ( ; entry < limit; entry++ )
|
for ( ; entry < limit; entry++ )
|
||||||
{
|
{
|
||||||
FT_Long diff = entry->Offset - pos;
|
FT_Long diff = (FT_Long)entry->Offset - pos;
|
||||||
|
|
||||||
|
|
||||||
if ( diff > 0 && diff < dist )
|
if ( diff > 0 && diff < dist )
|
||||||
|
@ -141,12 +141,12 @@
|
||||||
if ( entry == limit )
|
if ( entry == limit )
|
||||||
{
|
{
|
||||||
/* `loca' is the last table */
|
/* `loca' is the last table */
|
||||||
dist = stream->size - pos;
|
dist = (FT_Long)stream->size - pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( new_loca_len <= dist )
|
if ( new_loca_len <= (FT_ULong)dist )
|
||||||
{
|
{
|
||||||
face->num_locations = face->root.num_glyphs + 1;
|
face->num_locations = (FT_ULong)face->root.num_glyphs + 1;
|
||||||
table_len = new_loca_len;
|
table_len = new_loca_len;
|
||||||
|
|
||||||
FT_TRACE2(( "adjusting num_locations to %d\n",
|
FT_TRACE2(( "adjusting num_locations to %d\n",
|
||||||
|
|
Loading…
Reference in New Issue