diff options
Diffstat (limited to 'freetype/src/pfr/pfrsbit.c')
-rw-r--r-- | freetype/src/pfr/pfrsbit.c | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/freetype/src/pfr/pfrsbit.c b/freetype/src/pfr/pfrsbit.c index 979bf78a2..bb5df5c9f 100644 --- a/freetype/src/pfr/pfrsbit.c +++ b/freetype/src/pfr/pfrsbit.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR bitmap loader (body). */ /* */ -/* Copyright 2002, 2003, 2006, 2009, 2010, 2013 by */ +/* Copyright 2002-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -39,9 +39,9 @@ { FT_Byte* line; /* current line start */ FT_Int pitch; /* line size in bytes */ - FT_Int width; /* width in pixels/bits */ - FT_Int rows; /* number of remaining rows to scan */ - FT_Int total; /* total number of bits to draw */ + FT_UInt width; /* width in pixels/bits */ + FT_UInt rows; /* number of remaining rows to scan */ + FT_UInt total; /* total number of bits to draw */ } PFR_BitWriterRec, *PFR_BitWriter; @@ -59,7 +59,7 @@ if ( !decreasing ) { - writer->line += writer->pitch * ( target->rows - 1 ); + writer->line += writer->pitch * (FT_Int)( target->rows - 1 ); writer->pitch = -writer->pitch; } } @@ -70,15 +70,15 @@ FT_Byte* p, FT_Byte* limit ) { - FT_Int n, reload; - FT_Int left = writer->width; + FT_UInt n, reload; + FT_UInt left = writer->width; FT_Byte* cur = writer->line; FT_UInt mask = 0x80; FT_UInt val = 0; FT_UInt c = 0; - n = (FT_Int)( limit - p ) * 8; + n = (FT_UInt)( limit - p ) * 8; if ( n > writer->total ) n = writer->total; @@ -110,7 +110,7 @@ cur[0] = (FT_Byte)c; mask = 0x80; c = 0; - cur ++; + cur++; } } @@ -124,8 +124,9 @@ FT_Byte* p, FT_Byte* limit ) { - FT_Int n, phase, count, counts[2], reload; - FT_Int left = writer->width; + FT_Int phase, count, counts[2]; + FT_UInt n, reload; + FT_UInt left = writer->width; FT_Byte* cur = writer->line; FT_UInt mask = 0x80; FT_UInt c = 0; @@ -175,7 +176,7 @@ if ( --left <= 0 ) { - cur[0] = (FT_Byte) c; + cur[0] = (FT_Byte)c; left = writer->width; mask = 0x80; @@ -188,7 +189,7 @@ cur[0] = (FT_Byte)c; mask = 0x80; c = 0; - cur ++; + cur++; } reload = ( --count <= 0 ); @@ -204,8 +205,9 @@ FT_Byte* p, FT_Byte* limit ) { - FT_Int n, phase, count, reload; - FT_Int left = writer->width; + FT_Int phase, count; + FT_UInt n, reload; + FT_UInt left = writer->width; FT_Byte* cur = writer->line; FT_UInt mask = 0x80; FT_UInt c = 0; @@ -239,7 +241,7 @@ if ( --left <= 0 ) { - cur[0] = (FT_Byte) c; + cur[0] = (FT_Byte)c; c = 0; mask = 0x80; left = writer->width; @@ -252,7 +254,7 @@ cur[0] = (FT_Byte)c; c = 0; mask = 0x80; - cur ++; + cur++; } reload = ( --count <= 0 ); @@ -355,7 +357,8 @@ { FT_Error error = FT_Err_Ok; FT_Byte flags; - FT_Char b; + FT_Char c; + FT_Byte b; FT_Byte* p = *pdata; FT_Long xpos, ypos, advance; FT_UInt xsize, ysize; @@ -374,9 +377,9 @@ { case 0: PFR_CHECK( 1 ); - b = PFR_NEXT_INT8( p ); - xpos = b >> 4; - ypos = ( (FT_Char)( b << 4 ) ) >> 4; + c = PFR_NEXT_INT8( p ); + xpos = c >> 4; + ypos = ( (FT_Char)( c << 4 ) ) >> 4; break; case 1: @@ -609,8 +612,8 @@ advance = character->advance; if ( phys->metrics_resolution != phys->outline_resolution ) advance = FT_MulDiv( advance, - phys->outline_resolution, - phys->metrics_resolution ); + (FT_Long)phys->outline_resolution, + (FT_Long)phys->metrics_resolution ); glyph->root.linearHoriAdvance = advance; @@ -618,7 +621,7 @@ /* overridden in the bitmap header of certain glyphs. */ advance = FT_MulDiv( (FT_Fixed)size->root.metrics.x_ppem << 8, character->advance, - phys->metrics_resolution ); + (FT_Long)phys->metrics_resolution ); if ( FT_STREAM_SEEK( face->header.gps_section_offset + gps_offset ) || FT_FRAME_ENTER( gps_size ) ) @@ -632,12 +635,14 @@ &advance, &format ); /* - * XXX: on 16bit system, we return an error for huge bitmap - * which causes a size truncation, because truncated - * size properties makes bitmap glyph broken. + * XXX: on 16bit systems we return an error for huge bitmaps + * that cause size truncation, because truncated + * size properties make bitmap glyphs broken. */ - if ( xpos > FT_INT_MAX || xpos < FT_INT_MIN || - ysize > FT_INT_MAX || ypos + ysize > FT_INT_MAX || + if ( xpos > FT_INT_MAX || + xpos < FT_INT_MIN || + ysize > FT_INT_MAX || + ypos > FT_INT_MAX - (FT_Long)ysize || ypos + (FT_Long)ysize < FT_INT_MIN ) { FT_TRACE1(( "pfr_slot_load_bitmap:" )); @@ -653,8 +658,8 @@ /* Set up glyph bitmap and metrics */ /* XXX: needs casts to fit FT_Bitmap.{width|rows|pitch} */ - glyph->root.bitmap.width = (FT_Int)xsize; - glyph->root.bitmap.rows = (FT_Int)ysize; + glyph->root.bitmap.width = xsize; + glyph->root.bitmap.rows = ysize; glyph->root.bitmap.pitch = (FT_Int)( xsize + 7 ) >> 3; glyph->root.bitmap.pixel_mode = FT_PIXEL_MODE_MONO; @@ -670,11 +675,11 @@ /* XXX: needs casts fit FT_GlyphSlotRec.bitmap_{left|top} */ glyph->root.bitmap_left = (FT_Int)xpos; - glyph->root.bitmap_top = (FT_Int)(ypos + ysize); + glyph->root.bitmap_top = (FT_Int)( ypos + (FT_Long)ysize ); /* Allocate and read bitmap data */ { - FT_ULong len = glyph->root.bitmap.pitch * ysize; + FT_ULong len = (FT_ULong)glyph->root.bitmap.pitch * ysize; error = ft_glyphslot_alloc_bitmap( &glyph->root, len ); |