summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexei Podtelezhnikov <apodtele@gmail.com>2021-10-06 22:47:46 -0400
committerAlexei Podtelezhnikov <apodtele@gmail.com>2021-10-06 22:47:46 -0400
commit19ea07683f257ff35ed1515676086be3ebe514d9 (patch)
treea7dffae35a12b03dfd83325f66c41651be48b6ce
parent0f23ae2e80309d199ea6fea55691fa2d74bfed60 (diff)
downloadfreetype2-unsigned-revisions.tar.gz
Signedness revisions.unsigned-revisions
This eliminates explicit casting by switching to unsigned variables. The revised variables are frequently used together. * include/freetype/fttypes.h (FT_Data): Change to unsigned `length`. * include/freetype/internal/tttypes.h (TT_LoaderRec): Change to unsigned `byte_len`. * include/freetype/t1tables.h (CID_FaceInfoRec): Change to unsigned `gd_bytes` and `gd_bytes`. * src/cff/cffgload.c (cff_get_glyph_data, cff_free_glyph_data): Updated. * src/cid/cidgload.c (cid_load_glyph): Updated. * src/cid/cidload.h (cid_get_offset): Update argument. * src/cid/cidload.c (cid_get_offset, cid_face_open): Updated. * src/psaux/psft.c (cf2_getT1SeacComponent): Updated. * src/truetype/ttgload.c (TT_Process_Composite_Glyph, load_truetype_glyph): Updated.
-rw-r--r--include/freetype/fttypes.h2
-rw-r--r--include/freetype/internal/tttypes.h2
-rw-r--r--include/freetype/t1tables.h4
-rw-r--r--src/cff/cffgload.c4
-rw-r--r--src/cid/cidgload.c14
-rw-r--r--src/cid/cidload.c8
-rw-r--r--src/cid/cidload.h2
-rw-r--r--src/psaux/psft.c6
-rw-r--r--src/truetype/ttgload.c17
9 files changed, 29 insertions, 30 deletions
diff --git a/include/freetype/fttypes.h b/include/freetype/fttypes.h
index d5ca1c4f4..37f73538d 100644
--- a/include/freetype/fttypes.h
+++ b/include/freetype/fttypes.h
@@ -413,7 +413,7 @@ FT_BEGIN_HEADER
typedef struct FT_Data_
{
const FT_Byte* pointer;
- FT_Int length;
+ FT_UInt length;
} FT_Data;
diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h
index d0e9eeb44..651131c8d 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -1734,7 +1734,7 @@ FT_BEGIN_HEADER
FT_UInt glyph_index;
FT_Stream stream;
- FT_Int byte_len;
+ FT_UInt byte_len;
FT_Short n_contours;
FT_BBox bbox;
diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h
index 546ec1c00..bb9ee050f 100644
--- a/include/freetype/t1tables.h
+++ b/include/freetype/t1tables.h
@@ -415,8 +415,8 @@ FT_BEGIN_HEADER
FT_ULong xuid[16];
FT_ULong cidmap_offset;
- FT_Int fd_bytes;
- FT_Int gd_bytes;
+ FT_UInt fd_bytes;
+ FT_UInt gd_bytes;
FT_ULong cid_count;
FT_Int num_dicts;
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 831b3ae1d..97e8f9c1c 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -59,7 +59,7 @@
*pointer = (FT_Byte*)data.pointer;
- *length = (FT_ULong)data.length;
+ *length = data.length;
return error;
}
@@ -94,7 +94,7 @@
data.pointer = *pointer;
- data.length = (FT_Int)length;
+ data.length = (FT_UInt)length;
face->root.internal->incremental_interface->funcs->free_glyph_data(
face->root.internal->incremental_interface->object, &data );
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index bd0a7e7fb..e3e6832f6 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -63,7 +63,7 @@
#endif
- FT_TRACE1(( "cid_load_glyph: glyph index %d\n", glyph_index ));
+ FT_TRACE1(( "cid_load_glyph: glyph index %u\n", glyph_index ));
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -80,11 +80,11 @@
goto Exit;
p = (FT_Byte*)glyph_data.pointer;
- fd_select = cid_get_offset( &p, (FT_Byte)cid->fd_bytes );
+ fd_select = cid_get_offset( &p, cid->fd_bytes );
if ( glyph_data.length != 0 )
{
- glyph_length = (FT_ULong)( glyph_data.length - cid->fd_bytes );
+ glyph_length = glyph_data.length - cid->fd_bytes;
if ( !FT_QALLOC( charstring, glyph_length ) )
FT_MEM_COPY( charstring, glyph_data.pointer + cid->fd_bytes,
@@ -104,7 +104,7 @@
/* For ordinary fonts read the CID font dictionary index */
/* and charstring offset from the CIDMap. */
{
- FT_UInt entry_len = (FT_UInt)( cid->fd_bytes + cid->gd_bytes );
+ FT_UInt entry_len = cid->fd_bytes + cid->gd_bytes;
FT_ULong off1, off2;
@@ -114,10 +114,10 @@
goto Exit;
p = (FT_Byte*)stream->cursor;
- fd_select = cid_get_offset( &p, (FT_Byte)cid->fd_bytes );
- off1 = cid_get_offset( &p, (FT_Byte)cid->gd_bytes );
+ fd_select = cid_get_offset( &p, cid->fd_bytes );
+ off1 = cid_get_offset( &p, cid->gd_bytes );
p += cid->fd_bytes;
- off2 = cid_get_offset( &p, (FT_Byte)cid->gd_bytes );
+ off2 = cid_get_offset( &p, cid->gd_bytes );
FT_FRAME_EXIT();
if ( fd_select >= (FT_ULong)cid->num_dicts ||
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 768509a38..08c04c7cc 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -41,7 +41,7 @@
/* read a single offset */
FT_LOCAL_DEF( FT_ULong )
cid_get_offset( FT_Byte* *start,
- FT_Byte offsize )
+ FT_UInt offsize )
{
FT_ULong result;
FT_Byte* p = *start;
@@ -833,10 +833,10 @@
/* sanity tests */
- if ( cid->fd_bytes < 0 || cid->gd_bytes < 1 )
+ if ( cid->gd_bytes == 0 )
{
FT_ERROR(( "cid_face_open:"
- " Invalid `FDBytes' or `GDBytes' value\n" ));
+ " Invalid `GDBytes' value\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -853,7 +853,7 @@
}
binary_length = face->cid_stream->size - cid->data_offset;
- entry_len = (FT_ULong)( cid->fd_bytes + cid->gd_bytes );
+ entry_len = cid->fd_bytes + cid->gd_bytes;
for ( n = 0; n < cid->num_dicts; n++ )
{
diff --git a/src/cid/cidload.h b/src/cid/cidload.h
index 456685c2a..ee1d48650 100644
--- a/src/cid/cidload.h
+++ b/src/cid/cidload.h
@@ -37,7 +37,7 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_ULong )
cid_get_offset( FT_Byte** start,
- FT_Byte offsize );
+ FT_UInt offsize );
FT_LOCAL( FT_Error )
cid_face_open( CID_Face face,
diff --git a/src/psaux/psft.c b/src/psaux/psft.c
index 41c16542c..ac72d8259 100644
--- a/src/psaux/psft.c
+++ b/src/psaux/psft.c
@@ -742,13 +742,13 @@
/* For ordinary fonts get the character data stored in the face record. */
{
glyph_data.pointer = type1->charstrings[glyph_index];
- glyph_data.length = (FT_Int)type1->charstrings_len[glyph_index];
+ glyph_data.length = type1->charstrings_len[glyph_index];
}
if ( !error )
{
FT_Byte* charstring_base = (FT_Byte*)glyph_data.pointer;
- FT_ULong charstring_len = (FT_ULong)glyph_data.length;
+ FT_ULong charstring_len = glyph_data.length;
FT_ASSERT( charstring_base + charstring_len >= charstring_base );
@@ -778,7 +778,7 @@
face = (T1_Face)decoder->builder.face;
data.pointer = buf->start;
- data.length = (FT_Int)( buf->end - buf->start );
+ data.length = (FT_UInt)( buf->end - buf->start );
if ( face->root.internal->incremental_interface )
face->root.internal->incremental_interface->funcs->free_glyph_data(
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index bb948e43a..9136c171b 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1392,7 +1392,7 @@
FT_READ_USHORT( n_ins ) )
return error;
- FT_TRACE5(( " Instructions size = %d\n", n_ins ));
+ FT_TRACE5(( " Instructions size = %hu\n", n_ins ));
/* check it */
max_ins = loader->face->max_profile.maxSizeOfInstructions;
@@ -1400,10 +1400,10 @@
{
/* don't trust `maxSizeOfInstructions'; */
/* only do a rough safety check */
- if ( (FT_Int)n_ins > loader->byte_len )
+ if ( n_ins > loader->byte_len )
{
FT_TRACE1(( "TT_Process_Composite_Glyph:"
- " too many instructions (%d) for glyph with length %d\n",
+ " too many instructions (%hu) for glyph with length %u\n",
n_ins, loader->byte_len ));
return FT_THROW( Too_Many_Hints );
}
@@ -1686,7 +1686,7 @@
FT_ZERO( &inc_stream );
FT_Stream_OpenMemory( &inc_stream,
glyph_data.pointer,
- (FT_ULong)glyph_data.length );
+ glyph_data.length );
loader->stream = &inc_stream;
}
@@ -1694,8 +1694,7 @@
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- offset = tt_face_get_location( face, glyph_index,
- (FT_UInt*)&loader->byte_len );
+ offset = tt_face_get_location( face, glyph_index, &loader->byte_len );
if ( loader->byte_len > 0 )
{
@@ -1714,7 +1713,7 @@
error = face->access_glyph_frame( loader, glyph_index,
face->glyf_offset + offset,
- (FT_UInt)loader->byte_len );
+ loader->byte_len );
if ( error )
goto Exit;
@@ -1849,7 +1848,7 @@
/* (which consists of 10 bytes) */
error = face->access_glyph_frame( loader, glyph_index,
face->glyf_offset + offset + 10,
- (FT_UInt)loader->byte_len - 10 );
+ loader->byte_len - 10 );
if ( error )
goto Exit;
@@ -2105,7 +2104,7 @@
FT_UInt num_base_subgs = gloader->base.num_subglyphs;
FT_Stream old_stream = loader->stream;
- FT_Int old_byte_len = loader->byte_len;
+ FT_UInt old_byte_len = loader->byte_len;
FT_GlyphLoader_Add( gloader );