ref: 4f107450e2c073bc9f9401d9a58c620f74c9f3cd
parent: c70818a86218ba0b322102147d27de1b52b9db05
author: Werner Lemberg <[email protected]>
date: Sat May 17 08:07:45 EDT 2003
* 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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-05-15 David Turner <[email protected]>
+
+ * src/base/fttrigon.c (FT_Vector_Rotate): Avoid rounding errors
+ for small values.
+
+2003-05-15 Werner Lemberg <[email protected]>
+
+ * src/autohint/ahtypes.h (AH_PointRec): Remove unused `in_angle'
+ and `out_angle' fields.
+
2003-05-14 George Williams <[email protected]>
* src/base/ftmac.c (FT_New_Face_From_SFNT): Handle CFF files also.
--- a/src/autohint/ahtypes.h
+++ b/src/autohint/ahtypes.h
@@ -201,10 +201,6 @@
/* */
/* 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. */
@@ -219,9 +215,6 @@
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 */
--- 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
{