[cff] Make Adobe CFF engine work correctly on 64bit hosts.

Reported by numerous people on the `freetype-devel' list.  Without
this fix, glyphs aren't properly aligned on a common baseline.

On 64bit systems, `FT_Pos' expands to `long int', having a width of
64bit.  `CF2_Fixed' expands to `int' which is normally 32bit wide on
64bit hosts also.  Wrong casts filled up the blues arrays with
incorrect values.  Note that all blues values are accessed with the
`cf2_blueToFixed' macro which handles the 64bit to 32bit conversion.

* src/cff/cf2ft.h (cf2_getBlueValues, cf2_getOtherBlues,
cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Use `FT_Pos' for
`data', not `CF2_Fixed'.
* src/cff/cf2ft.c (cf2_getBlueValues, cf2_getOtherBlues,
cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Updated.
* src/cff/cf2blues.c (cf2_blues_init): Updated.
This commit is contained in:
Werner Lemberg 2013-05-04 18:04:07 +02:00
parent 94152819b0
commit 77c39b1deb
4 changed files with 37 additions and 17 deletions

View File

@ -1,3 +1,23 @@
2013-05-04 Werner Lemberg <wl@gnu.org>
[cff] Make Adobe CFF engine work correctly on 64bit hosts.
Reported by numerous people on the `freetype-devel' list. Without
this fix, glyphs aren't properly aligned on a common baseline.
On 64bit systems, `FT_Pos' expands to `long int', having a width of
64bit. `CF2_Fixed' expands to `int' which is normally 32bit wide on
64bit hosts also. Wrong casts filled up the blues arrays with
incorrect values. Note that all blues values are accessed with the
`cf2_blueToFixed' macro which handles the 64bit to 32bit conversion.
* src/cff/cf2ft.h (cf2_getBlueValues, cf2_getOtherBlues,
cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Use `FT_Pos' for
`data', not `CF2_Fixed'.
* src/cff/cf2ft.c (cf2_getBlueValues, cf2_getOtherBlues,
cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Updated.
* src/cff/cf2blues.c (cf2_blues_init): Updated.
2013-05-04 Werner Lemberg <wl@gnu.org>
More fixes for clang's `sanitize' feature.
@ -537,7 +557,7 @@
[sfnt] Fix broken pointer overflow checks.
Many compilers such as gcc and clang optimize away pointer overflow
checks `p + n < p', because pointer overflow is undefined behavior.
checks `p + n < p', because pointer overflow is undefined behavior.
Use a safe form `n > p_limit - p' instead.
Also avoid possible integer overflow issues, for example, using

View File

@ -78,10 +78,10 @@
size_t numFamilyBlues;
size_t numFamilyOtherBlues;
CF2_Fixed* blueValues;
CF2_Fixed* otherBlues;
CF2_Fixed* familyBlues;
CF2_Fixed* familyOtherBlues;
FT_Pos* blueValues;
FT_Pos* otherBlues;
FT_Pos* familyBlues;
FT_Pos* familyOtherBlues;
size_t i;
CF2_Fixed emBoxBottom, emBoxTop;

View File

@ -432,12 +432,12 @@
FT_LOCAL_DEF( void )
cf2_getBlueValues( CFF_Decoder* decoder,
size_t* count,
CF2_Fixed* *data )
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
*count = decoder->current_subfont->private_dict.num_blue_values;
*data = (CF2_Fixed*)
*data = (FT_Pos*)
&decoder->current_subfont->private_dict.blue_values;
}
@ -445,12 +445,12 @@
FT_LOCAL_DEF( void )
cf2_getOtherBlues( CFF_Decoder* decoder,
size_t* count,
CF2_Fixed* *data )
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
*count = decoder->current_subfont->private_dict.num_other_blues;
*data = (CF2_Fixed*)
*data = (FT_Pos*)
&decoder->current_subfont->private_dict.other_blues;
}
@ -458,12 +458,12 @@
FT_LOCAL_DEF( void )
cf2_getFamilyBlues( CFF_Decoder* decoder,
size_t* count,
CF2_Fixed* *data )
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
*count = decoder->current_subfont->private_dict.num_family_blues;
*data = (CF2_Fixed*)
*data = (FT_Pos*)
&decoder->current_subfont->private_dict.family_blues;
}
@ -471,12 +471,12 @@
FT_LOCAL_DEF( void )
cf2_getFamilyOtherBlues( CFF_Decoder* decoder,
size_t* count,
CF2_Fixed* *data )
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
*count = decoder->current_subfont->private_dict.num_family_other_blues;
*data = (CF2_Fixed*)
*data = (FT_Pos*)
&decoder->current_subfont->private_dict.family_other_blues;
}

View File

@ -80,19 +80,19 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
cf2_getBlueValues( CFF_Decoder* decoder,
size_t* count,
CF2_Fixed* *data );
FT_Pos* *data );
FT_LOCAL( void )
cf2_getOtherBlues( CFF_Decoder* decoder,
size_t* count,
CF2_Fixed* *data );
FT_Pos* *data );
FT_LOCAL( void )
cf2_getFamilyBlues( CFF_Decoder* decoder,
size_t* count,
CF2_Fixed* *data );
FT_Pos* *data );
FT_LOCAL( void )
cf2_getFamilyOtherBlues( CFF_Decoder* decoder,
size_t* count,
CF2_Fixed* *data );
FT_Pos* *data );
FT_LOCAL( CF2_Int )
cf2_getLanguageGroup( CFF_Decoder* decoder );