From 4f107450e2c073bc9f9401d9a58c620f74c9f3cd Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sat, 17 May 2003 12:07:45 +0000 Subject: [PATCH] * src/base/fttrigon.c (FT_Vector_Rotate): Avoid rounding errors for small values. * src/autohint/ahtypes.h (AH_PointRec): Remove unused `in_angle' and `out_angle' fields. --- ChangeLog | 10 ++++++++++ src/autohint/ahtypes.h | 7 ------- src/base/fttrigon.c | 21 ++++++++++++++++----- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4f976c15b..7d17814ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-05-15 David Turner + + * src/base/fttrigon.c (FT_Vector_Rotate): Avoid rounding errors + for small values. + +2003-05-15 Werner Lemberg + + * src/autohint/ahtypes.h (AH_PointRec): Remove unused `in_angle' + and `out_angle' fields. + 2003-05-14 George Williams * src/base/ftmac.c (FT_New_Face_From_SFNT): Handle CFF files also. diff --git a/src/autohint/ahtypes.h b/src/autohint/ahtypes.h index 5ad62ba4f..947ee6241 100644 --- a/src/autohint/ahtypes.h +++ b/src/autohint/ahtypes.h @@ -201,10 +201,6 @@ FT_BEGIN_HEADER /* */ /* out_dir :: The direction of the outwards vector (point->next). */ /* */ - /* in_angle :: The angle of the inwards vector. */ - /* */ - /* out_angle :: The angle of the outwards vector. */ - /* */ /* next :: The next point in same contour. */ /* */ /* prev :: The previous point in same contour. */ @@ -220,9 +216,6 @@ FT_BEGIN_HEADER AH_Direction in_dir; /* direction of inwards vector */ AH_Direction out_dir; /* direction of outwards vector */ - AH_Angle in_angle; - AH_Angle out_angle; - AH_Point next; /* next point in contour */ AH_Point prev; /* previous point in contour */ diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c index 5bf55eb7c..fc48d6c2e 100644 --- a/src/base/fttrigon.c +++ b/src/base/fttrigon.c @@ -356,6 +356,14 @@ } + /* these macros return 0 for positive numbers, + and -1 for negative ones */ +#define FT_SIGN_LONG( x ) ( (x) >> ( FT_SIZEOF_LONG * 8 - 1 ) ) +#define FT_SIGN_INT( x ) ( (x) >> ( FT_SIZEOF_INT * 8 - 1 ) ) +#define FT_SIGN_INT32( x ) ( (x) >> 31 ) +#define FT_SIGN_INT16( x ) ( (x) >> 15 ) + + /* documentation is in fttrigon.h */ FT_EXPORT_DEF( void ) @@ -366,8 +374,8 @@ FT_Vector v; - v.x = vec->x; - v.y = vec->y; + v.x = vec->x; + v.y = vec->y; if ( angle && ( v.x != 0 || v.y != 0 ) ) { @@ -376,10 +384,13 @@ v.x = ft_trig_downscale( v.x ); v.y = ft_trig_downscale( v.y ); - if ( shift >= 0 ) + if ( shift > 0 ) { - vec->x = v.x >> shift; - vec->y = v.y >> shift; + FT_Int32 half = 1L << ( shift - 1 ); + + + vec->x = ( v.x + half + FT_SIGN_LONG( v.x ) ) >> shift; + vec->y = ( v.y + half + FT_SIGN_LONG( v.y ) ) >> shift; } else {