[pfr] Signedness fixes. * src/pfr/pfrdrivr.c, src/pfr/pfrgload.c, src/pfr/pfrload.c, src/pfr/pfrload.h, src/pfr/pfrobjs.c, src/pfr/pfrsbit.c, src/pfr/pfrtypes.h: Apply.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
diff --git a/ChangeLog b/ChangeLog
index 94e69b7..87e35f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2015-02-21 Werner Lemberg <wl@gnu.org>
+ [pfr] Signedness fixes.
+
+ * src/pfr/pfrdrivr.c, src/pfr/pfrgload.c, src/pfr/pfrload.c,
+ src/pfr/pfrload.h, src/pfr/pfrobjs.c, src/pfr/pfrsbit.c,
+ src/pfr/pfrtypes.h: Apply.
+
+2015-02-21 Werner Lemberg <wl@gnu.org>
+
[cff] Minor signedness fixes related to last commit.
* src/cff/cf2ft.c, src/cff/cf2intrp.c, src/cff/cffgload.c: Apply.
diff --git a/src/pfr/pfrdrivr.c b/src/pfr/pfrdrivr.c
index 9d344d1..bc9d1f8 100644
--- a/src/pfr/pfrdrivr.c
+++ b/src/pfr/pfrdrivr.c
@@ -43,12 +43,14 @@
if ( phys->outline_resolution != phys->metrics_resolution )
{
if ( avector->x != 0 )
- avector->x = FT_MulDiv( avector->x, phys->outline_resolution,
- phys->metrics_resolution );
+ avector->x = FT_MulDiv( avector->x,
+ (FT_Long)phys->outline_resolution,
+ (FT_Long)phys->metrics_resolution );
if ( avector->y != 0 )
- avector->y = FT_MulDiv( avector->x, phys->outline_resolution,
- phys->metrics_resolution );
+ avector->y = FT_MulDiv( avector->x,
+ (FT_Long)phys->outline_resolution,
+ (FT_Long)phys->metrics_resolution );
}
return FT_Err_Ok;
@@ -118,10 +120,10 @@
if ( size )
{
x_scale = FT_DivFix( size->metrics.x_ppem << 6,
- phys->metrics_resolution );
+ (FT_Long)phys->metrics_resolution );
y_scale = FT_DivFix( size->metrics.y_ppem << 6,
- phys->metrics_resolution );
+ (FT_Long)phys->metrics_resolution );
}
if ( ametrics_x_scale )
diff --git a/src/pfr/pfrgload.c b/src/pfr/pfrgload.c
index 1d27437..1cd13c2 100644
--- a/src/pfr/pfrgload.c
+++ b/src/pfr/pfrgload.c
@@ -143,7 +143,7 @@
error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 0 );
if ( !error )
{
- FT_UInt n = outline->n_points;
+ FT_Int n = outline->n_points;
outline->points[n] = *to;
@@ -693,7 +693,7 @@
if ( format & PFR_SUBGLYPH_3BYTE_OFFSET )
{
PFR_CHECK( 3 );
- subglyph->gps_offset = PFR_NEXT_LONG( p );
+ subglyph->gps_offset = PFR_NEXT_ULONG( p );
}
else
{
@@ -736,7 +736,7 @@
if ( size > 0 && *p & PFR_GLYPH_IS_COMPOUND )
{
- FT_Int n, old_count, count;
+ FT_UInt n, old_count, count;
FT_GlyphLoader loader = glyph->loader;
FT_Outline* base = &loader->base.outline;
diff --git a/src/pfr/pfrload.c b/src/pfr/pfrload.c
index 31177c0..ec7311d 100644
--- a/src/pfr/pfrload.c
+++ b/src/pfr/pfrload.c
@@ -199,7 +199,7 @@
FT_LOCAL_DEF( FT_Error )
pfr_log_font_count( FT_Stream stream,
FT_UInt32 section_offset,
- FT_UInt *acount )
+ FT_Long *acount )
{
FT_Error error;
FT_UInt count;
@@ -212,7 +212,7 @@
result = count;
Exit:
- *acount = result;
+ *acount = (FT_Long)result;
return error;
}
@@ -535,7 +535,8 @@
item->pair_count = PFR_NEXT_BYTE( p );
item->base_adj = PFR_NEXT_SHORT( p );
item->flags = PFR_NEXT_BYTE( p );
- item->offset = phy_font->offset + ( p - phy_font->cursor );
+ item->offset = phy_font->offset +
+ (FT_Offset)( p - phy_font->cursor );
#ifndef PFR_CONFIG_NO_CHECKS
item->pair_size = 3;
@@ -864,7 +865,7 @@
phy_font->num_chars = count = PFR_NEXT_USHORT( p );
- phy_font->chars_offset = offset + ( p - stream->cursor );
+ phy_font->chars_offset = offset + (FT_Offset)( p - stream->cursor );
if ( FT_NEW_ARRAY( phy_font->chars, count ) )
goto Fail;
@@ -898,7 +899,7 @@
cur->advance = ( flags & PFR_PHY_PROPORTIONAL )
? PFR_NEXT_SHORT( p )
- : (FT_Int) phy_font->standard_advance;
+ : phy_font->standard_advance;
#if 0
cur->ascii = ( flags & PFR_PHY_ASCII_CODE )
diff --git a/src/pfr/pfrload.h b/src/pfr/pfrload.h
index c5b8d66..0a51234 100644
--- a/src/pfr/pfrload.h
+++ b/src/pfr/pfrload.h
@@ -85,7 +85,7 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
pfr_log_font_count( FT_Stream stream,
FT_UInt32 log_section_offset,
- FT_UInt *acount );
+ FT_Long *acount );
/* load a pfr logical font entry */
FT_LOCAL( FT_Error )
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index 1c8683e..edd9c7f 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -94,7 +94,7 @@
/* check face index */
{
- FT_UInt num_faces;
+ FT_Long num_faces;
error = pfr_log_font_count( stream,
@@ -118,7 +118,7 @@
/* load the face */
error = pfr_log_font_load(
- &face->log_font, stream, face_index,
+ &face->log_font, stream, (FT_UInt)face_index,
face->header.log_dir_offset,
FT_BOOL( face->header.phy_font_max_size_high != 0 ) );
if ( error )
@@ -137,7 +137,7 @@
pfrface->face_index = face_index;
- pfrface->num_glyphs = phy_font->num_chars + 1;
+ pfrface->num_glyphs = (FT_Long)phy_font->num_chars + 1;
pfrface->face_flags |= FT_FACE_FLAG_SCALABLE;
@@ -218,13 +218,13 @@
strike = phy_font->strikes;
for ( n = 0; n < count; n++, size++, strike++ )
{
- size->height = (FT_UShort)strike->y_ppm;
- size->width = (FT_UShort)strike->x_ppm;
- size->size = strike->y_ppm << 6;
- size->x_ppem = strike->x_ppm << 6;
- size->y_ppem = strike->y_ppm << 6;
+ size->height = (FT_Short)strike->y_ppm;
+ size->width = (FT_Short)strike->x_ppm;
+ size->size = (FT_Pos)( strike->y_ppm << 6 );
+ size->x_ppem = (FT_Pos)( strike->x_ppm << 6 );
+ size->y_ppem = (FT_Pos)( strike->y_ppm << 6 );
}
- pfrface->num_fixed_sizes = count;
+ pfrface->num_fixed_sizes = (FT_Int)count;
}
/* now compute maximum advance width */
@@ -366,7 +366,7 @@
FT_BBox cbox;
FT_Glyph_Metrics* metrics = &pfrslot->metrics;
FT_Pos advance;
- FT_Int em_metrics, em_outline;
+ FT_UInt em_metrics, em_outline;
FT_Bool scaling;
@@ -390,7 +390,9 @@
em_outline = face->phy_font.outline_resolution;
if ( em_metrics != em_outline )
- advance = FT_MulDiv( advance, em_outline, em_metrics );
+ advance = FT_MulDiv( advance,
+ (FT_Long)em_outline,
+ (FT_Long)em_metrics );
if ( face->phy_font.flags & PFR_PHY_VERTICAL )
metrics->vertAdvance = advance;
diff --git a/src/pfr/pfrsbit.c b/src/pfr/pfrsbit.c
index 280cf2a..bb5df5c 100644
--- a/src/pfr/pfrsbit.c
+++ b/src/pfr/pfrsbit.c
@@ -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 );
diff --git a/src/pfr/pfrtypes.h b/src/pfr/pfrtypes.h
index 9af906e..5ffb1b1 100644
--- a/src/pfr/pfrtypes.h
+++ b/src/pfr/pfrtypes.h
@@ -229,7 +229,7 @@ FT_BEGIN_HEADER
FT_UInt metrics_resolution;
FT_BBox bbox;
FT_UInt flags;
- FT_UInt standard_advance;
+ FT_Int standard_advance;
FT_Int ascent; /* optional, bbox.yMax if not present */
FT_Int descent; /* optional, bbox.yMin if not present */
@@ -260,7 +260,7 @@ FT_BEGIN_HEADER
PFR_KernItem* kern_items_tail;
/* not part of the spec, but used during load */
- FT_Long bct_offset;
+ FT_ULong bct_offset;
FT_Byte* cursor;
} PFR_PhyFontRec, *PFR_PhyFont;