[sfnt] Signedness fixes.
* src/sfnt/pngshim.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap.c, src/sfnt/ttkern.c, src/sfnt/ttload.c, src/sfnt/ttpost.c, src/sfnt/ttsbit.c: Apply. * src/sfnt/sfdriver.c: Apply. (sfnt_get_ps_name): Simplify.
This commit is contained in:
parent
3c374c8cda
commit
01f0842eb0
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2015-02-22 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
|
[sfnt] Signedness fixes.
|
||||||
|
|
||||||
|
* src/sfnt/pngshim.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap.c,
|
||||||
|
src/sfnt/ttkern.c, src/sfnt/ttload.c, src/sfnt/ttpost.c,
|
||||||
|
src/sfnt/ttsbit.c: Apply.
|
||||||
|
* src/sfnt/sfdriver.c: Apply.
|
||||||
|
(sfnt_get_ps_name): Simplify.
|
||||||
|
|
||||||
2015-02-22 Werner Lemberg <wl@gnu.org>
|
2015-02-22 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
[bdf] Signedness fixes.
|
[bdf] Signedness fixes.
|
||||||
|
|
|
@ -37,11 +37,11 @@
|
||||||
/* This code is freely based on cairo-png.c. There's so many ways */
|
/* This code is freely based on cairo-png.c. There's so many ways */
|
||||||
/* to call libpng, and the way cairo does it is defacto standard. */
|
/* to call libpng, and the way cairo does it is defacto standard. */
|
||||||
|
|
||||||
static int
|
static unsigned int
|
||||||
multiply_alpha( int alpha,
|
multiply_alpha( unsigned int alpha,
|
||||||
int color )
|
unsigned int color )
|
||||||
{
|
{
|
||||||
int temp = ( alpha * color ) + 0x80;
|
unsigned int temp = alpha * color + 0x80;
|
||||||
|
|
||||||
|
|
||||||
return ( temp + ( temp >> 8 ) ) >> 8;
|
return ( temp + ( temp >> 8 ) ) >> 8;
|
||||||
|
@ -82,10 +82,10 @@
|
||||||
blue = multiply_alpha( alpha, blue );
|
blue = multiply_alpha( alpha, blue );
|
||||||
}
|
}
|
||||||
|
|
||||||
base[0] = blue;
|
base[0] = (unsigned char)blue;
|
||||||
base[1] = green;
|
base[1] = (unsigned char)green;
|
||||||
base[2] = red;
|
base[2] = (unsigned char)red;
|
||||||
base[3] = alpha;
|
base[3] = (unsigned char)alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,9 +110,9 @@
|
||||||
unsigned int blue = base[2];
|
unsigned int blue = base[2];
|
||||||
|
|
||||||
|
|
||||||
base[0] = blue;
|
base[0] = (unsigned char)blue;
|
||||||
base[1] = green;
|
base[1] = (unsigned char)green;
|
||||||
base[2] = red;
|
base[2] = (unsigned char)red;
|
||||||
base[3] = 0xFF;
|
base[3] = 0xFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,16 +258,16 @@
|
||||||
|
|
||||||
if ( populate_map_and_metrics )
|
if ( populate_map_and_metrics )
|
||||||
{
|
{
|
||||||
FT_Long size;
|
FT_ULong size;
|
||||||
|
|
||||||
|
|
||||||
metrics->width = (FT_Int)imgWidth;
|
metrics->width = (FT_UShort)imgWidth;
|
||||||
metrics->height = (FT_Int)imgHeight;
|
metrics->height = (FT_UShort)imgHeight;
|
||||||
|
|
||||||
map->width = metrics->width;
|
map->width = metrics->width;
|
||||||
map->rows = metrics->height;
|
map->rows = metrics->height;
|
||||||
map->pixel_mode = FT_PIXEL_MODE_BGRA;
|
map->pixel_mode = FT_PIXEL_MODE_BGRA;
|
||||||
map->pitch = map->width * 4;
|
map->pitch = (int)( map->width * 4 );
|
||||||
map->num_grays = 256;
|
map->num_grays = 256;
|
||||||
|
|
||||||
/* reject too large bitmaps similarly to the rasterizer */
|
/* reject too large bitmaps similarly to the rasterizer */
|
||||||
|
@ -278,7 +278,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this doesn't overflow: 0x7FFF * 0x7FFF * 4 < 2^32 */
|
/* this doesn't overflow: 0x7FFF * 0x7FFF * 4 < 2^32 */
|
||||||
size = map->rows * map->pitch;
|
size = map->rows * (FT_ULong)map->pitch;
|
||||||
|
|
||||||
error = ft_glyphslot_alloc_bitmap( slot, size );
|
error = ft_glyphslot_alloc_bitmap( slot, size );
|
||||||
if ( error )
|
if ( error )
|
||||||
|
|
|
@ -266,7 +266,7 @@
|
||||||
{
|
{
|
||||||
FT_Stream stream = face->name_table.stream;
|
FT_Stream stream = face->name_table.stream;
|
||||||
FT_String* r = (FT_String*)result;
|
FT_String* r = (FT_String*)result;
|
||||||
FT_Byte* p;
|
FT_Char* p;
|
||||||
|
|
||||||
|
|
||||||
if ( FT_STREAM_SEEK( name->stringOffset ) ||
|
if ( FT_STREAM_SEEK( name->stringOffset ) ||
|
||||||
|
@ -280,11 +280,11 @@
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = (FT_Byte*)stream->cursor;
|
p = (FT_Char*)stream->cursor;
|
||||||
|
|
||||||
for ( ; len > 0; len--, p += 2 )
|
for ( ; len > 0; len--, p += 2 )
|
||||||
{
|
{
|
||||||
if ( p[0] == 0 && p[1] >= 32 && p[1] < 128 )
|
if ( p[0] == 0 && p[1] >= 32 )
|
||||||
*r++ = p[1];
|
*r++ = p[1];
|
||||||
}
|
}
|
||||||
*r = '\0';
|
*r = '\0';
|
||||||
|
|
|
@ -580,8 +580,8 @@
|
||||||
table->OrigOffset = sfnt_offset;
|
table->OrigOffset = sfnt_offset;
|
||||||
|
|
||||||
/* The offsets must be multiples of 4. */
|
/* The offsets must be multiples of 4. */
|
||||||
woff_offset += ( table->CompLength + 3 ) & ~3;
|
woff_offset += ( table->CompLength + 3 ) & ~3U;
|
||||||
sfnt_offset += ( table->OrigLength + 3 ) & ~3;
|
sfnt_offset += ( table->OrigLength + 3 ) & ~3U;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -609,7 +609,7 @@
|
||||||
if ( woff.privOffset )
|
if ( woff.privOffset )
|
||||||
{
|
{
|
||||||
/* ... if it isn't the last block. */
|
/* ... if it isn't the last block. */
|
||||||
woff_offset = ( woff_offset + 3 ) & ~3;
|
woff_offset = ( woff_offset + 3 ) & ~3U;
|
||||||
|
|
||||||
if ( woff.privOffset != woff_offset ||
|
if ( woff.privOffset != woff_offset ||
|
||||||
woff.privOffset + woff.privLength > woff.length )
|
woff.privOffset + woff.privLength > woff.length )
|
||||||
|
@ -1431,8 +1431,8 @@
|
||||||
root->ascender = face->horizontal.Ascender;
|
root->ascender = face->horizontal.Ascender;
|
||||||
root->descender = face->horizontal.Descender;
|
root->descender = face->horizontal.Descender;
|
||||||
|
|
||||||
root->height = (FT_Short)( root->ascender - root->descender +
|
root->height = root->ascender - root->descender +
|
||||||
face->horizontal.Line_Gap );
|
face->horizontal.Line_Gap;
|
||||||
|
|
||||||
if ( !( root->ascender || root->descender ) )
|
if ( !( root->ascender || root->descender ) )
|
||||||
{
|
{
|
||||||
|
@ -1443,23 +1443,24 @@
|
||||||
root->ascender = face->os2.sTypoAscender;
|
root->ascender = face->os2.sTypoAscender;
|
||||||
root->descender = face->os2.sTypoDescender;
|
root->descender = face->os2.sTypoDescender;
|
||||||
|
|
||||||
root->height = (FT_Short)( root->ascender - root->descender +
|
root->height = root->ascender - root->descender +
|
||||||
face->os2.sTypoLineGap );
|
face->os2.sTypoLineGap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
root->ascender = (FT_Short)face->os2.usWinAscent;
|
root->ascender = (FT_Short)face->os2.usWinAscent;
|
||||||
root->descender = -(FT_Short)face->os2.usWinDescent;
|
root->descender = -(FT_Short)face->os2.usWinDescent;
|
||||||
|
|
||||||
root->height = (FT_UShort)( root->ascender - root->descender );
|
root->height = root->ascender - root->descender;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
root->max_advance_width = face->horizontal.advance_Width_Max;
|
root->max_advance_width =
|
||||||
root->max_advance_height = (FT_Short)( face->vertical_info
|
(FT_Short)face->horizontal.advance_Width_Max;
|
||||||
? face->vertical.advance_Height_Max
|
root->max_advance_height =
|
||||||
: root->height );
|
(FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max
|
||||||
|
: root->height );
|
||||||
|
|
||||||
/* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */
|
/* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */
|
||||||
/* Adjust underline position from top edge to centre of */
|
/* Adjust underline position from top edge to centre of */
|
||||||
|
|
|
@ -360,7 +360,7 @@
|
||||||
|
|
||||||
|
|
||||||
ids = p - 2 + offset;
|
ids = p - 2 + offset;
|
||||||
if ( ids < glyph_ids || ids + code_count*2 > table + length )
|
if ( ids < glyph_ids || ids + code_count * 2 > table + length )
|
||||||
FT_INVALID_OFFSET;
|
FT_INVALID_OFFSET;
|
||||||
|
|
||||||
/* check glyph IDs */
|
/* check glyph IDs */
|
||||||
|
@ -375,7 +375,7 @@
|
||||||
idx = TT_NEXT_USHORT( p );
|
idx = TT_NEXT_USHORT( p );
|
||||||
if ( idx != 0 )
|
if ( idx != 0 )
|
||||||
{
|
{
|
||||||
idx = ( idx + delta ) & 0xFFFFU;
|
idx = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
|
||||||
if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
|
if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
|
||||||
FT_INVALID_GLYPH_ID;
|
FT_INVALID_GLYPH_ID;
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@
|
||||||
idx = TT_PEEK_USHORT( p );
|
idx = TT_PEEK_USHORT( p );
|
||||||
|
|
||||||
if ( idx != 0 )
|
if ( idx != 0 )
|
||||||
result = (FT_UInt)( idx + delta ) & 0xFFFFU;
|
result = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -524,7 +524,7 @@
|
||||||
|
|
||||||
if ( idx != 0 )
|
if ( idx != 0 )
|
||||||
{
|
{
|
||||||
gindex = ( idx + delta ) & 0xFFFFU;
|
gindex = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
|
||||||
if ( gindex != 0 )
|
if ( gindex != 0 )
|
||||||
{
|
{
|
||||||
result = charcode;
|
result = charcode;
|
||||||
|
@ -786,7 +786,7 @@
|
||||||
|
|
||||||
if ( gindex != 0 )
|
if ( gindex != 0 )
|
||||||
{
|
{
|
||||||
gindex = (FT_UInt)( ( gindex + delta ) & 0xFFFFU );
|
gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
|
||||||
if ( gindex != 0 )
|
if ( gindex != 0 )
|
||||||
{
|
{
|
||||||
cmap->cur_charcode = charcode;
|
cmap->cur_charcode = charcode;
|
||||||
|
@ -800,7 +800,7 @@
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
FT_UInt gindex = (FT_UInt)( ( charcode + delta ) & 0xFFFFU );
|
FT_UInt gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
|
||||||
|
|
||||||
|
|
||||||
if ( gindex != 0 )
|
if ( gindex != 0 )
|
||||||
|
@ -993,7 +993,7 @@
|
||||||
idx = FT_NEXT_USHORT( p );
|
idx = FT_NEXT_USHORT( p );
|
||||||
if ( idx != 0 )
|
if ( idx != 0 )
|
||||||
{
|
{
|
||||||
idx = (FT_UInt)( idx + delta ) & 0xFFFFU;
|
idx = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
|
||||||
|
|
||||||
if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
|
if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
|
||||||
FT_INVALID_GLYPH_ID;
|
FT_INVALID_GLYPH_ID;
|
||||||
|
@ -1090,10 +1090,10 @@
|
||||||
p += offset + ( charcode - start ) * 2;
|
p += offset + ( charcode - start ) * 2;
|
||||||
gindex = TT_PEEK_USHORT( p );
|
gindex = TT_PEEK_USHORT( p );
|
||||||
if ( gindex != 0 )
|
if ( gindex != 0 )
|
||||||
gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU;
|
gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gindex = (FT_UInt)( charcode + delta ) & 0xFFFFU;
|
gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1294,10 +1294,10 @@
|
||||||
p += offset + ( charcode - start ) * 2;
|
p += offset + ( charcode - start ) * 2;
|
||||||
gindex = TT_PEEK_USHORT( p );
|
gindex = TT_PEEK_USHORT( p );
|
||||||
if ( gindex != 0 )
|
if ( gindex != 0 )
|
||||||
gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU;
|
gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gindex = (FT_UInt)( charcode + delta ) & 0xFFFFU;
|
gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,8 +108,8 @@
|
||||||
p_next = p_limit;
|
p_next = p_limit;
|
||||||
|
|
||||||
/* only use horizontal kerning tables */
|
/* only use horizontal kerning tables */
|
||||||
if ( ( coverage & ~8 ) != 0x0001 ||
|
if ( ( coverage & ~8U ) != 0x0001 ||
|
||||||
p + 8 > p_limit )
|
p + 8 > p_limit )
|
||||||
goto NextTable;
|
goto NextTable;
|
||||||
|
|
||||||
num_pairs = FT_NEXT_USHORT( p );
|
num_pairs = FT_NEXT_USHORT( p );
|
||||||
|
|
|
@ -421,7 +421,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* make metrics table length a multiple of 4 */
|
/* make metrics table length a multiple of 4 */
|
||||||
entry->Length = ( stream->size - entry->Offset ) & ~3;
|
entry->Length = ( stream->size - entry->Offset ) & ~3U;
|
||||||
|
|
||||||
FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx"
|
FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx"
|
||||||
" (sanitized; original length %08lx)\n",
|
" (sanitized; original length %08lx)\n",
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
|
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
|
||||||
|
|
||||||
#define MAC_NAME( x ) ( (FT_String*)psnames->macintosh_name( x ) )
|
#define MAC_NAME( x ) (FT_String*)psnames->macintosh_name( (FT_UInt)(x) )
|
||||||
|
|
||||||
|
|
||||||
#else /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
|
#else /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
/* table of Mac names. Thus, it is possible to build a version of */
|
/* table of Mac names. Thus, it is possible to build a version of */
|
||||||
/* FreeType without the Type 1 driver & PSNames module. */
|
/* FreeType without the Type 1 driver & PSNames module. */
|
||||||
|
|
||||||
#define MAC_NAME( x ) ( (FT_String*)tt_post_default_names[x] )
|
#define MAC_NAME( x ) (FT_String*)tt_post_default_names[x]
|
||||||
|
|
||||||
/* the 258 default Mac PS glyph names; see file `tools/glnames.py' */
|
/* the 258 default Mac PS glyph names; see file `tools/glnames.py' */
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
static FT_Error
|
static FT_Error
|
||||||
load_format_20( TT_Face face,
|
load_format_20( TT_Face face,
|
||||||
FT_Stream stream,
|
FT_Stream stream,
|
||||||
FT_Long post_limit )
|
FT_ULong post_limit )
|
||||||
{
|
{
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
|
@ -243,8 +243,8 @@
|
||||||
goto Fail1;
|
goto Fail1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (FT_Int)len > post_limit ||
|
if ( len > post_limit ||
|
||||||
FT_STREAM_POS() > post_limit - (FT_Int)len )
|
FT_STREAM_POS() > post_limit - len )
|
||||||
{
|
{
|
||||||
FT_ERROR(( "load_format_20:"
|
FT_ERROR(( "load_format_20:"
|
||||||
" exceeding string length (%d),"
|
" exceeding string length (%d),"
|
||||||
|
@ -307,7 +307,7 @@
|
||||||
static FT_Error
|
static FT_Error
|
||||||
load_format_25( TT_Face face,
|
load_format_25( TT_Face face,
|
||||||
FT_Stream stream,
|
FT_Stream stream,
|
||||||
FT_Long post_limit )
|
FT_ULong post_limit )
|
||||||
{
|
{
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
|
@ -377,7 +377,7 @@
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
FT_Fixed format;
|
FT_Fixed format;
|
||||||
FT_ULong post_len;
|
FT_ULong post_len;
|
||||||
FT_Long post_limit;
|
FT_ULong post_limit;
|
||||||
|
|
||||||
|
|
||||||
/* get a stream for the face's resource */
|
/* get a stream for the face's resource */
|
||||||
|
@ -547,10 +547,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( idx < (FT_UInt)table->num_glyphs ) /* paranoid checking */
|
if ( idx < (FT_UInt)table->num_glyphs ) /* paranoid checking */
|
||||||
{
|
*PSname = MAC_NAME( (FT_Int)idx + table->offsets[idx] );
|
||||||
idx += table->offsets[idx];
|
|
||||||
*PSname = MAC_NAME( idx );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nothing to do for format == 0x00030000L */
|
/* nothing to do for format == 0x00030000L */
|
||||||
|
|
|
@ -101,10 +101,10 @@
|
||||||
|
|
||||||
p = face->sbit_table;
|
p = face->sbit_table;
|
||||||
|
|
||||||
version = FT_NEXT_ULONG( p );
|
version = FT_NEXT_LONG( p );
|
||||||
num_strikes = FT_NEXT_ULONG( p );
|
num_strikes = FT_NEXT_ULONG( p );
|
||||||
|
|
||||||
if ( ( version & 0xFFFF0000UL ) != 0x00020000UL )
|
if ( ( (FT_ULong)version & 0xFFFF0000UL ) != 0x00020000UL )
|
||||||
{
|
{
|
||||||
error = FT_THROW( Unknown_File_Format );
|
error = FT_THROW( Unknown_File_Format );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
@ -273,6 +273,7 @@
|
||||||
FT_UShort ppem, resolution;
|
FT_UShort ppem, resolution;
|
||||||
TT_HoriHeader *hori;
|
TT_HoriHeader *hori;
|
||||||
FT_ULong table_size;
|
FT_ULong table_size;
|
||||||
|
FT_Pos ppem_, upem_; /* to reduce casts */
|
||||||
|
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
FT_Byte* p;
|
FT_Byte* p;
|
||||||
|
@ -305,12 +306,15 @@
|
||||||
metrics->x_ppem = ppem;
|
metrics->x_ppem = ppem;
|
||||||
metrics->y_ppem = ppem;
|
metrics->y_ppem = ppem;
|
||||||
|
|
||||||
metrics->ascender = ppem * hori->Ascender * 64 / upem;
|
ppem_ = (FT_Pos)ppem;
|
||||||
metrics->descender = ppem * hori->Descender * 64 / upem;
|
upem_ = (FT_Pos)upem;
|
||||||
metrics->height = ppem * ( hori->Ascender -
|
|
||||||
hori->Descender +
|
metrics->ascender = ppem_ * hori->Ascender * 64 / upem_;
|
||||||
hori->Line_Gap ) * 64 / upem;
|
metrics->descender = ppem_ * hori->Descender * 64 / upem_;
|
||||||
metrics->max_advance = ppem * hori->advance_Width_Max * 64 / upem;
|
metrics->height = ppem_ * ( hori->Ascender -
|
||||||
|
hori->Descender +
|
||||||
|
hori->Line_Gap ) * 64 / upem_;
|
||||||
|
metrics->max_advance = ppem_ * hori->advance_Width_Max * 64 / upem_;
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +424,7 @@
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
FT_UInt width, height;
|
FT_UInt width, height;
|
||||||
FT_Bitmap* map = decoder->bitmap;
|
FT_Bitmap* map = decoder->bitmap;
|
||||||
FT_Long size;
|
FT_ULong size;
|
||||||
|
|
||||||
|
|
||||||
if ( !decoder->metrics_loaded )
|
if ( !decoder->metrics_loaded )
|
||||||
|
@ -432,38 +436,38 @@
|
||||||
width = decoder->metrics->width;
|
width = decoder->metrics->width;
|
||||||
height = decoder->metrics->height;
|
height = decoder->metrics->height;
|
||||||
|
|
||||||
map->width = (int)width;
|
map->width = width;
|
||||||
map->rows = (int)height;
|
map->rows = height;
|
||||||
|
|
||||||
switch ( decoder->bit_depth )
|
switch ( decoder->bit_depth )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
map->pixel_mode = FT_PIXEL_MODE_MONO;
|
map->pixel_mode = FT_PIXEL_MODE_MONO;
|
||||||
map->pitch = ( map->width + 7 ) >> 3;
|
map->pitch = (int)( ( map->width + 7 ) >> 3 );
|
||||||
map->num_grays = 2;
|
map->num_grays = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
map->pixel_mode = FT_PIXEL_MODE_GRAY2;
|
map->pixel_mode = FT_PIXEL_MODE_GRAY2;
|
||||||
map->pitch = ( map->width + 3 ) >> 2;
|
map->pitch = (int)( ( map->width + 3 ) >> 2 );
|
||||||
map->num_grays = 4;
|
map->num_grays = 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
map->pixel_mode = FT_PIXEL_MODE_GRAY4;
|
map->pixel_mode = FT_PIXEL_MODE_GRAY4;
|
||||||
map->pitch = ( map->width + 1 ) >> 1;
|
map->pitch = (int)( ( map->width + 1 ) >> 1 );
|
||||||
map->num_grays = 16;
|
map->num_grays = 16;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
map->pixel_mode = FT_PIXEL_MODE_GRAY;
|
map->pixel_mode = FT_PIXEL_MODE_GRAY;
|
||||||
map->pitch = map->width;
|
map->pitch = (int)( map->width );
|
||||||
map->num_grays = 256;
|
map->num_grays = 256;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 32:
|
case 32:
|
||||||
map->pixel_mode = FT_PIXEL_MODE_BGRA;
|
map->pixel_mode = FT_PIXEL_MODE_BGRA;
|
||||||
map->pitch = map->width * 4;
|
map->pitch = (int)( map->width * 4 );
|
||||||
map->num_grays = 256;
|
map->num_grays = 256;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -472,7 +476,7 @@
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = map->rows * map->pitch;
|
size = map->rows * (FT_ULong)map->pitch;
|
||||||
|
|
||||||
/* check that there is no empty image */
|
/* check that there is no empty image */
|
||||||
if ( size == 0 )
|
if ( size == 0 )
|
||||||
|
@ -561,7 +565,8 @@
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
FT_Byte* line;
|
FT_Byte* line;
|
||||||
FT_Int bit_height, bit_width, pitch, width, height, line_bits, h;
|
FT_Int pitch, width, height, line_bits, h;
|
||||||
|
FT_UInt bit_height, bit_width;
|
||||||
FT_Bitmap* bitmap;
|
FT_Bitmap* bitmap;
|
||||||
|
|
||||||
|
|
||||||
|
@ -577,8 +582,8 @@
|
||||||
|
|
||||||
line_bits = width * decoder->bit_depth;
|
line_bits = width * decoder->bit_depth;
|
||||||
|
|
||||||
if ( x_pos < 0 || x_pos + width > bit_width ||
|
if ( x_pos < 0 || (FT_UInt)( x_pos + width ) > bit_width ||
|
||||||
y_pos < 0 || y_pos + height > bit_height )
|
y_pos < 0 || (FT_UInt)( y_pos + height ) > bit_height )
|
||||||
{
|
{
|
||||||
FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned:"
|
FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned:"
|
||||||
" invalid bitmap dimensions\n" ));
|
" invalid bitmap dimensions\n" ));
|
||||||
|
@ -699,7 +704,8 @@
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
FT_Byte* line;
|
FT_Byte* line;
|
||||||
FT_Int bit_height, bit_width, pitch, width, height, line_bits, h, nbits;
|
FT_Int pitch, width, height, line_bits, h, nbits;
|
||||||
|
FT_UInt bit_height, bit_width;
|
||||||
FT_Bitmap* bitmap;
|
FT_Bitmap* bitmap;
|
||||||
FT_UShort rval;
|
FT_UShort rval;
|
||||||
|
|
||||||
|
@ -716,8 +722,8 @@
|
||||||
|
|
||||||
line_bits = width * decoder->bit_depth;
|
line_bits = width * decoder->bit_depth;
|
||||||
|
|
||||||
if ( x_pos < 0 || x_pos + width > bit_width ||
|
if ( x_pos < 0 || (FT_UInt)( x_pos + width ) > bit_width ||
|
||||||
y_pos < 0 || y_pos + height > bit_height )
|
y_pos < 0 || (FT_UInt)( y_pos + height ) > bit_height )
|
||||||
{
|
{
|
||||||
FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned:"
|
FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned:"
|
||||||
" invalid bitmap dimensions\n" ));
|
" invalid bitmap dimensions\n" ));
|
||||||
|
@ -1379,9 +1385,9 @@
|
||||||
|
|
||||||
metrics->horiBearingX = (FT_Short)originOffsetX;
|
metrics->horiBearingX = (FT_Short)originOffsetX;
|
||||||
metrics->horiBearingY = (FT_Short)( -originOffsetY + metrics->height );
|
metrics->horiBearingY = (FT_Short)( -originOffsetY + metrics->height );
|
||||||
metrics->horiAdvance = (FT_Short)( aadvance *
|
metrics->horiAdvance = (FT_UShort)( aadvance *
|
||||||
face->root.size->metrics.x_ppem /
|
face->root.size->metrics.x_ppem /
|
||||||
face->header.Units_Per_EM );
|
face->header.Units_Per_EM );
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
|
Loading…
Reference in New Issue