diff options
author | Alexei Podtelezhnikov <apodtele@gmail.com> | 2018-06-28 21:42:26 -0400 |
---|---|---|
committer | Alexei Podtelezhnikov <apodtele@gmail.com> | 2018-06-28 21:42:26 -0400 |
commit | 1fc776b5f14e2be6fa3d6573f5cd3fb88a7ae468 (patch) | |
tree | f8fdf35d1a785e1a59c610cd1fde7963962c93ae | |
parent | 4f11209f5cd4f83f185042d54ad1c892dffb5ed1 (diff) | |
download | freetype2-1fc776b5f14e2be6fa3d6573f5cd3fb88a7ae468.tar.gz |
* src/base/fttrigon.c (FT_Tan): Improve accuracy.
(FT_Vector_Rotate): Simplify.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/base/fttrigon.c | 16 |
2 files changed, 9 insertions, 12 deletions
@@ -1,5 +1,10 @@ 2018-06-28 Alexei Podtelezhnikov <apodtele@gmail.com> + * src/base/fttrigon.c (FT_Tan): Improve accuracy. + (FT_Vector_Rotate): Simplify. + +2018-06-28 Alexei Podtelezhnikov <apodtele@gmail.com> + * src/base/ftobjs.c (FT_Set_Charmap): Robustify. 2018-06-25 Werner Lemberg <wl@gnu.org> diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c index 6a10492b2..d375bd730 100644 --- a/src/base/fttrigon.c +++ b/src/base/fttrigon.c @@ -325,10 +325,10 @@ FT_EXPORT_DEF( FT_Fixed ) FT_Tan( FT_Angle angle ) { - FT_Vector v; + FT_Vector v = { 1 << 24, 0 }; - FT_Vector_Unit( &v, angle ); + ft_trig_pseudo_rotate( &v, angle ); return FT_DivFix( v.y, v.x ); } @@ -372,14 +372,6 @@ } - /* 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 ) @@ -408,8 +400,8 @@ FT_Int32 half = (FT_Int32)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; + vec->x = ( v.x + half - ( v.x < 0 ) ) >> shift; + vec->y = ( v.y + half - ( v.y < 0 ) ) >> shift; } else { |