- added a new function called FT_SqrtFixed to compute the 16.16 square root of a 16.16 number (this could come handy in a later version of the auto-hinter) - small fixes to the smooth renderer. It used to use way too much line segments when drawing beziers !!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
diff --git a/include/freetype/internal/ftcalc.h b/include/freetype/internal/ftcalc.h
index 27b8415..45313f3 100644
--- a/include/freetype/internal/ftcalc.h
+++ b/include/freetype/internal/ftcalc.h
@@ -34,9 +34,7 @@
#define ADD_64( x, y, z ) z = (x) + (y)
#define MUL_64( x, y, z ) z = (FT_Int64)(x) * (y)
-
-#define DIV_64( x, y ) ( (x) / (y) )
-
+#define DIV_64( x, y ) ((x)/(y))
#ifdef FT_CONFIG_OPTION_OLD_CALCS
@@ -62,7 +60,6 @@
#define MUL_64( x, y, z ) FT_MulTo64( x, y, &z )
#define DIV_64( x, y ) FT_Div64by32( &x, y )
-
FT_EXPORT_DEF( void ) FT_Add64( FT_Int64* x,
FT_Int64* y,
FT_Int64* z );
@@ -77,6 +74,8 @@
#ifdef FT_CONFIG_OPTION_OLD_CALCS
+ FT_EXPORT_DEF(FT_Int32) FT_SqrtFixed( FT_Int32 x );
+
#define SQRT_64( z ) FT_Sqrt64( &z )
FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64* x );
diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h
index 48403ec..bb4dabc 100644
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -65,8 +65,8 @@
FT_Long size,
void** P );
- BASE_DEF( void ) FT_Free( FT_Memory memory,
- void** P );
+ BASE_DEF( void ) FT_Free( FT_Memory memory,
+ void** P );
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index d27de26..7c4fc2e 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -295,6 +295,15 @@
return r;
}
+
+ FT_EXPORT_DEF(FT_Int32) FT_SqrtFixed( FT_Int32 x )
+ {
+ FT_Int64 z;
+
+ z = (FT_Int64)(x) << 16;
+ return FT_Sqrt64( z );
+ }
+
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
@@ -488,21 +497,14 @@
else
{
/* we need more bits; we have to do it by hand */
- FT_UInt32 c;
-
-
- q = ( a / b ) << 16;
- c = a % b;
-
- /* we must compute C*0x10000/B: we simply shift C and B so */
- /* C becomes smaller than 16 bits */
- while ( c >> 16 )
- {
- c >>= 1;
- b <<= 1;
- }
+ FT_Int64 temp, temp2;
- q += ( c << 16 ) / b;
+ temp.hi = (FT_Int32) (a >> 16);
+ temp.lo = (FT_UInt32)(a << 16);
+ temp2.hi = (FT_Int32)( b >> 31 );
+ temp2.lo = (FT_UInt32)( b / 2 );
+ FT_Add64( &temp, &temp2, &temp );
+ q = FT_Div64by32( &temp, b );
}
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
@@ -765,6 +767,16 @@
return r;
}
+
+ FT_EXPORT_DEF(FT_Int32) FT_SqrtFixed( FT_Int32 x )
+ {
+ FT_Int64 z;
+
+ z.hi = (FT_UInt32)((FT_Int32)(x) >> 16);
+ z.lo = (FT_UInt32)( x << 16 );
+ return FT_Sqrt64( &z );
+ }
+
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
#endif /* FT_LONG64 */
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 7ed0838..17b9ffe 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -726,7 +726,7 @@
dx = dx / ras.conic_level;
while ( dx > 0 )
{
- dx >>= 1;
+ dx >>= 2;
level++;
}
@@ -874,8 +874,8 @@
db = db / ras.conic_level;
while ( da > 0 || db > 0 )
{
- da >>= 1;
- db >>= 2;
+ da >>= 2;
+ db >>= 3;
level++;
}
@@ -1740,7 +1740,7 @@
if ( ras.max_ex > 24 || ras.max_ey > 24 )
level++;
if ( ras.max_ex > 120 || ras.max_ey > 120 )
- level += 2;
+ level ++;
ras.conic_level <<= level;
ras.cubic_level <<= level;