diff --git a/ChangeLog b/ChangeLog index fa11b21a9..9d2bd2a1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-07-16 Jon Foster + + * src/pfr/pfrdrivr.c (pfr_get_advance): Fix off-by-one error. + + * src/base/ftcalc.c (FT_MulFix): Fix portability issue. + + * src/sfnt/ttpost.c (MAC_NAME) [!FT_CONFIG_OPTION_POSTSCRIPT_NAMES]: + Fix compiler warning. + 2008-07-16 Werner Lemberg Handle CID-keyed fonts wrapped in a SFNT (with cmaps) correctly. diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index 549427a86..7d2381bbd 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -437,7 +437,14 @@ ); return result; -#elif 1 +#elif 0 + + /* + * This code is nonportable. See comment below. + * + * However, on a platform where right-shift of a signed quantity fills + * the leftmost bits by copying the sign bit, it might be faster. + */ FT_Long sa, sb; FT_ULong ua, ub; @@ -446,6 +453,24 @@ if ( a == 0 || b == 0x10000L ) return a; + /* + * This is a clever way of converting a signed number `a' into its + * absolute value (stored back into `a') and its sign. The sign is + * stored in `sa'; 0 means `a' was positive or zero, and -1 means `a' + * was negative. (Similarly for `b' and `sb'). + * + * Unfortunately, it doesn't work (at least not portably). + * + * It makes the assumption that right-shift on a negative signed value + * fills the leftmost bits by copying the sign bit. This is wrong. + * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206, + * the result of right-shift of a negative signed value is + * implementation-defined. At least one implementation fills the + * leftmost bits with 0s (i.e., it is exactly the same as an unsigned + * right shift). This means that when `a' is negative, `sa' ends up + * with the value 1 rather than -1. After that, everything else goes + * wrong. + */ sa = ( a >> ( sizeof ( a ) * 8 - 1 ) ); a = ( a ^ sa ) - sa; sb = ( b >> ( sizeof ( b ) * 8 - 1 ) ); diff --git a/src/pfr/pfrdrivr.c b/src/pfr/pfrdrivr.c index 40206720e..b65850b61 100644 --- a/src/pfr/pfrdrivr.c +++ b/src/pfr/pfrdrivr.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR driver interface (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2006 by */ +/* Copyright 2002, 2003, 2004, 2006, 2008 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -70,6 +70,12 @@ *anadvance = 0; + + if ( !gindex ) + goto Exit; + + gindex--; + if ( face ) { PFR_PhyFont phys = &face->phy_font; @@ -82,6 +88,7 @@ } } + Exit: return error; } diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c index 1e6163646..eebebdba7 100644 --- a/src/sfnt/ttpost.c +++ b/src/sfnt/ttpost.c @@ -5,7 +5,7 @@ /* Postcript name table processing for TrueType and OpenType fonts */ /* (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2006, 2007 by */ +/* Copyright 1996-2001, 2002, 2003, 2006, 2007, 2008 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -62,7 +62,7 @@ /* table of Mac names. Thus, it is possible to build a version of */ /* FreeType without the Type 1 driver & PSNames module. */ -#define MAC_NAME( x ) tt_post_default_names[x] +#define MAC_NAME( x ) ( (FT_String*)tt_post_default_names[x] ) /* the 258 default Mac PS glyph names */