aboutsummaryrefslogtreecommitdiff
path: root/freetype/src/bdf
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-12-21 15:22:51 +0000
committermarha <marha@users.sourceforge.net>2009-12-21 15:22:51 +0000
commit1ee02cd0419021c3d4950af2619da39c6e9c47f0 (patch)
treef5b61f7d9e151c7a64cff51399560ffb77800349 /freetype/src/bdf
parentd8432fdd4f13e9f9d1d44f5482faeb56562661a9 (diff)
downloadvcxsrv-1ee02cd0419021c3d4950af2619da39c6e9c47f0.tar.gz
vcxsrv-1ee02cd0419021c3d4950af2619da39c6e9c47f0.tar.bz2
vcxsrv-1ee02cd0419021c3d4950af2619da39c6e9c47f0.zip
Updated to freetype-2.3.11
Diffstat (limited to 'freetype/src/bdf')
-rw-r--r--freetype/src/bdf/bdf.h6
-rw-r--r--freetype/src/bdf/bdfdrivr.c68
-rw-r--r--freetype/src/bdf/bdfdrivr.h4
-rw-r--r--freetype/src/bdf/bdflib.c78
4 files changed, 93 insertions, 63 deletions
diff --git a/freetype/src/bdf/bdf.h b/freetype/src/bdf/bdf.h
index 1b64426aa..561b4158a 100644
--- a/freetype/src/bdf/bdf.h
+++ b/freetype/src/bdf/bdf.h
@@ -114,8 +114,8 @@ FT_BEGIN_HEADER
union
{
char* atom;
- long int32;
- unsigned long card32;
+ long l;
+ unsigned long ul;
} value; /* Value of the property. */
@@ -160,7 +160,7 @@ FT_BEGIN_HEADER
typedef struct _hashnode_
{
const char* key;
- void* data;
+ size_t data;
} _hashnode, *hashnode;
diff --git a/freetype/src/bdf/bdfdrivr.c b/freetype/src/bdf/bdfdrivr.c
index 0b736b5ce..631ec460e 100644
--- a/freetype/src/bdf/bdfdrivr.c
+++ b/freetype/src/bdf/bdfdrivr.c
@@ -53,7 +53,7 @@ THE SOFTWARE.
typedef struct BDF_CMapRec_
{
FT_CMapRec cmap;
- FT_UInt num_encodings;
+ FT_ULong num_encodings; /* ftobjs.h: FT_CMap->clazz->size */
BDF_encoding_el* encodings;
} BDF_CMapRec, *BDF_CMap;
@@ -92,8 +92,8 @@ THE SOFTWARE.
{
BDF_CMap cmap = (BDF_CMap)bdfcmap;
BDF_encoding_el* encodings = cmap->encodings;
- FT_UInt min, max, mid;
- FT_UInt result = 0;
+ FT_ULong min, max, mid; /* num_encodings */
+ FT_UShort result = 0; /* encodings->glyph */
min = 0;
@@ -101,7 +101,7 @@ THE SOFTWARE.
while ( min < max )
{
- FT_UInt32 code;
+ FT_ULong code;
mid = ( min + max ) >> 1;
@@ -131,9 +131,9 @@ THE SOFTWARE.
{
BDF_CMap cmap = (BDF_CMap)bdfcmap;
BDF_encoding_el* encodings = cmap->encodings;
- FT_UInt min, max, mid;
- FT_UInt32 charcode = *acharcode + 1;
- FT_UInt result = 0;
+ FT_ULong min, max, mid; /* num_encodings */
+ FT_UShort result = 0; /* encodings->glyph */
+ FT_ULong charcode = *acharcode + 1;
min = 0;
@@ -141,7 +141,7 @@ THE SOFTWARE.
while ( min < max )
{
- FT_UInt32 code;
+ FT_ULong code; /* same as BDF_encoding_el.enc */
mid = ( min + max ) >> 1;
@@ -169,7 +169,14 @@ THE SOFTWARE.
}
Exit:
- *acharcode = charcode;
+ if ( charcode > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "bdf_cmap_char_next: charcode 0x%x > 32bit API" ));
+ *acharcode = 0;
+ /* XXX: result should be changed to indicate an overflow error */
+ }
+ else
+ *acharcode = (FT_UInt32)charcode;
return result;
}
@@ -196,9 +203,8 @@ THE SOFTWARE.
bdf_font_t* font = bdf->bdffont;
bdf_property_t* prop;
- int nn, len;
- char* strings[4] = { NULL, NULL, NULL, NULL };
- int lengths[4];
+ char* strings[4] = { NULL, NULL, NULL, NULL };
+ size_t nn, len, lengths[4];
face->style_flags = 0;
@@ -284,7 +290,7 @@ THE SOFTWARE.
/* add_style_name and setwidth_name */
if ( nn == 0 || nn == 3 )
{
- int mm;
+ size_t mm;
for ( mm = 0; mm < len; mm++ )
@@ -426,7 +432,7 @@ THE SOFTWARE.
prop = bdf_get_font_property( font, "AVERAGE_WIDTH" );
if ( prop )
- bsize->width = (FT_Short)( ( prop->value.int32 + 5 ) / 10 );
+ bsize->width = (FT_Short)( ( prop->value.l + 5 ) / 10 );
else
bsize->width = (FT_Short)( bsize->height * 2/3 );
@@ -434,21 +440,21 @@ THE SOFTWARE.
if ( prop )
/* convert from 722.7 decipoints to 72 points per inch */
bsize->size =
- (FT_Pos)( ( prop->value.int32 * 64 * 7200 + 36135L ) / 72270L );
+ (FT_Pos)( ( prop->value.l * 64 * 7200 + 36135L ) / 72270L );
else
bsize->size = bsize->width << 6;
prop = bdf_get_font_property( font, "PIXEL_SIZE" );
if ( prop )
- bsize->y_ppem = (FT_Short)prop->value.int32 << 6;
+ bsize->y_ppem = (FT_Short)prop->value.l << 6;
prop = bdf_get_font_property( font, "RESOLUTION_X" );
if ( prop )
- resolution_x = (FT_Short)prop->value.int32;
+ resolution_x = (FT_Short)prop->value.l;
prop = bdf_get_font_property( font, "RESOLUTION_Y" );
if ( prop )
- resolution_y = (FT_Short)prop->value.int32;
+ resolution_y = (FT_Short)prop->value.l;
if ( bsize->y_ppem == 0 )
{
@@ -479,7 +485,12 @@ THE SOFTWARE.
(face->en_table[n]).glyph = (FT_Short)n;
if ( cur[n].encoding == font->default_char )
- face->default_glyph = n;
+ {
+ if ( n < FT_UINT_MAX )
+ face->default_glyph = (FT_UInt)n;
+ else
+ FT_TRACE1(( "idx %d is too large for this system\n", n ));
+ }
}
}
@@ -671,7 +682,10 @@ THE SOFTWARE.
bitmap->rows = glyph.bbx.height;
bitmap->width = glyph.bbx.width;
- bitmap->pitch = glyph.bpr;
+ if ( glyph.bpr > INT_MAX )
+ FT_TRACE1(( "BDF_Glyph_Load: too large pitch %d is truncated\n",
+ glyph.bpr ));
+ bitmap->pitch = (int)glyph.bpr; /* same as FT_Bitmap.pitch */
/* note: we don't allocate a new array to hold the bitmap; */
/* we can simply point to it */
@@ -743,13 +757,23 @@ THE SOFTWARE.
break;
case BDF_INTEGER:
+ if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) )
+ {
+ FT_TRACE1(( "bdf_get_bdf_property: " ));
+ FT_TRACE1(( "too large integer 0x%x is truncated\n" ));
+ }
aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
- aproperty->u.integer = prop->value.int32;
+ aproperty->u.integer = (FT_Int32)prop->value.l;
break;
case BDF_CARDINAL:
+ if ( prop->value.ul > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "bdf_get_bdf_property: " ));
+ FT_TRACE1(( "too large cardinal 0x%x is truncated\n" ));
+ }
aproperty->type = BDF_PROPERTY_TYPE_CARDINAL;
- aproperty->u.cardinal = prop->value.card32;
+ aproperty->u.cardinal = (FT_UInt32)prop->value.ul;
break;
default:
diff --git a/freetype/src/bdf/bdfdrivr.h b/freetype/src/bdf/bdfdrivr.h
index 86f40ee4a..db7093bb4 100644
--- a/freetype/src/bdf/bdfdrivr.h
+++ b/freetype/src/bdf/bdfdrivr.h
@@ -36,6 +36,10 @@ THE SOFTWARE.
FT_BEGIN_HEADER
+#ifdef FT_CONFIG_OPTION_PIC
+#error "this module does not support PIC yet"
+#endif
+
typedef struct BDF_encoding_el_
{
diff --git a/freetype/src/bdf/bdflib.c b/freetype/src/bdf/bdflib.c
index 5435b20e6..5fa5868c7 100644
--- a/freetype/src/bdf/bdflib.c
+++ b/freetype/src/bdf/bdflib.c
@@ -281,7 +281,7 @@
static FT_Error
hash_insert( char* key,
- void* data,
+ size_t data,
hashtable* ht,
FT_Memory memory )
{
@@ -415,18 +415,18 @@
static FT_Error
- _bdf_list_ensure( _bdf_list_t* list,
- int num_items )
+ _bdf_list_ensure( _bdf_list_t* list,
+ unsigned long num_items ) /* same as _bdf_list_t.used */
{
FT_Error error = BDF_Err_Ok;
- if ( num_items > (int)list->size )
+ if ( num_items > list->size )
{
- int oldsize = list->size;
- int newsize = oldsize + ( oldsize >> 1 ) + 4;
- int bigsize = FT_INT_MAX / sizeof ( char* );
- FT_Memory memory = list->memory;
+ unsigned long oldsize = list->size; /* same as _bdf_list_t.size */
+ unsigned long newsize = oldsize + ( oldsize >> 1 ) + 4;
+ unsigned long bigsize = (unsigned long)( FT_INT_MAX / sizeof ( char* ) );
+ FT_Memory memory = list->memory;
if ( oldsize == bigsize )
@@ -614,8 +614,8 @@
{
_bdf_line_func_t cb;
unsigned long lineno, buf_size;
- int refill, bytes, hold, to_skip;
- int start, end, cursor, avail;
+ int refill, hold, to_skip;
+ ptrdiff_t bytes, start, end, cursor, avail;
char* buf = 0;
FT_Memory memory = stream->memory;
FT_Error error = BDF_Err_Ok;
@@ -648,8 +648,8 @@
{
if ( refill )
{
- bytes = (int)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor,
- (FT_ULong)(buf_size - cursor) );
+ bytes = (ptrdiff_t)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor,
+ (FT_ULong)(buf_size - cursor) );
avail = cursor + bytes;
cursor = 0;
refill = 0;
@@ -971,7 +971,7 @@
int format,
bdf_font_t* font )
{
- unsigned long n;
+ size_t n;
bdf_property_t* p;
FT_Memory memory = font->memory;
FT_Error error = BDF_Err_Ok;
@@ -991,7 +991,9 @@
p = font->user_props + font->nuser_props;
FT_ZERO( p );
- n = (unsigned long)( ft_strlen( name ) + 1 );
+ n = ft_strlen( name ) + 1;
+ if ( n > FT_ULONG_MAX )
+ return BDF_Err_Invalid_Argument;
if ( FT_NEW_ARRAY( p->name, n ) )
goto Exit;
@@ -1003,7 +1005,7 @@
n = _num_bdf_properties + font->nuser_props;
- error = hash_insert( p->name, (void *)n, &(font->proptbl), memory );
+ error = hash_insert( p->name, n, &(font->proptbl), memory );
if ( error )
goto Exit;
@@ -1018,8 +1020,8 @@
bdf_get_property( char* name,
bdf_font_t* font )
{
- hashnode hn;
- unsigned long propid;
+ hashnode hn;
+ size_t propid;
if ( name == 0 || *name == 0 )
@@ -1028,7 +1030,7 @@
if ( ( hn = hash_lookup( name, &(font->proptbl) ) ) == 0 )
return 0;
- propid = (unsigned long)hn->data;
+ propid = hn->data;
if ( propid >= _num_bdf_properties )
return font->user_props + ( propid - _num_bdf_properties );
@@ -1131,11 +1133,11 @@
_bdf_set_default_spacing( bdf_font_t* font,
bdf_options_t* opts )
{
- unsigned long len;
- char name[256];
- _bdf_list_t list;
- FT_Memory memory;
- FT_Error error = BDF_Err_Ok;
+ size_t len;
+ char name[256];
+ _bdf_list_t list;
+ FT_Memory memory;
+ FT_Error error = BDF_Err_Ok;
if ( font == 0 || font->name == 0 || font->name[0] == 0 )
@@ -1150,7 +1152,7 @@
font->spacing = opts->font_spacing;
- len = (unsigned long)( ft_strlen( font->name ) + 1 );
+ len = ft_strlen( font->name ) + 1;
/* Limit ourselves to 256 characters in the font name. */
if ( len >= 256 )
{
@@ -1261,7 +1263,7 @@
char* name,
char* value )
{
- unsigned long propid;
+ size_t propid;
hashnode hn;
bdf_property_t *prop, *fp;
FT_Memory memory = font->memory;
@@ -1273,7 +1275,7 @@
{
/* The property already exists in the font, so simply replace */
/* the value of the property with the current value. */
- fp = font->props + (unsigned long)hn->data;
+ fp = font->props + hn->data;
switch ( fp->format )
{
@@ -1289,11 +1291,11 @@
break;
case BDF_INTEGER:
- fp->value.int32 = _bdf_atol( value, 0, 10 );
+ fp->value.l = _bdf_atol( value, 0, 10 );
break;
case BDF_CARDINAL:
- fp->value.card32 = _bdf_atoul( value, 0, 10 );
+ fp->value.ul = _bdf_atoul( value, 0, 10 );
break;
default:
@@ -1335,7 +1337,7 @@
font->props_size++;
}
- propid = (unsigned long)hn->data;
+ propid = hn->data;
if ( propid >= _num_bdf_properties )
prop = font->user_props + ( propid - _num_bdf_properties );
else
@@ -1359,11 +1361,11 @@
break;
case BDF_INTEGER:
- fp->value.int32 = _bdf_atol( value, 0, 10 );
+ fp->value.l = _bdf_atol( value, 0, 10 );
break;
case BDF_CARDINAL:
- fp->value.card32 = _bdf_atoul( value, 0, 10 );
+ fp->value.ul = _bdf_atoul( value, 0, 10 );
break;
}
@@ -1372,7 +1374,7 @@
if ( ft_memcmp( name, "COMMENT", 7 ) != 0 ) {
/* Add the property to the font property table. */
error = hash_insert( fp->name,
- (void *)font->props_used,
+ font->props_used,
(hashtable *)font->internal,
memory );
if ( error )
@@ -1387,11 +1389,11 @@
/* present, and the SPACING property should override the default */
/* spacing. */
if ( ft_memcmp( name, "DEFAULT_CHAR", 12 ) == 0 )
- font->default_char = fp->value.int32;
+ font->default_char = fp->value.l;
else if ( ft_memcmp( name, "FONT_ASCENT", 11 ) == 0 )
- font->font_ascent = fp->value.int32;
+ font->font_ascent = fp->value.l;
else if ( ft_memcmp( name, "FONT_DESCENT", 12 ) == 0 )
- font->font_descent = fp->value.int32;
+ font->font_descent = fp->value.l;
else if ( ft_memcmp( name, "SPACING", 7 ) == 0 )
{
if ( !fp->value.atom )
@@ -2044,7 +2046,7 @@
p->memory = 0;
{ /* setup */
- unsigned long i;
+ size_t i;
bdf_property_t* prop;
@@ -2054,7 +2056,7 @@
for ( i = 0, prop = (bdf_property_t*)_bdf_properties;
i < _num_bdf_properties; i++, prop++ )
{
- error = hash_insert( prop->name, (void *)i,
+ error = hash_insert( prop->name, i,
&(font->proptbl), memory );
if ( error )
goto Exit;
@@ -2472,7 +2474,7 @@
hn = hash_lookup( name, (hashtable *)font->internal );
- return hn ? ( font->props + (unsigned long)hn->data ) : 0;
+ return hn ? ( font->props + hn->data ) : 0;
}