shithub: freetype+ttf2subf

Download patch

ref: 1c5802a4b2d0d12634edb1e82420e62a9f7178ea
parent: ea5a981c7d000b11cf29dd7f1a9cf96defdff059
author: David Turner <[email protected]>
date: Thu Oct 18 05:51:09 EDT 2001

updated FT_Div64by32

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
+2001-10-18  David Turner  <[email protected]>
+
+        * src/base/ftcalc.c (FT_Div64by32): changed the implementation
+        slightly since the original code was mis-compiled on Mac machines
+        using the MPW C compiler..
+
+
 2001-10-17  David Turner  >[email protected]>
 
+	* Version 2.0.4 released.
+	=========================
+
 	* include/freetype/freetype.h, include/internal/ftobjs.h,
 	src/base/ftobjs.c, src/sfnt/sfdriver.c, type1/t1driver.c,
 	cid/cidriver.c: Adding a new function named 'FT_Get_Postscript_Name' to
@@ -7,6 +17,7 @@
 	formats except pure CFF/CEF fonts (this will be added soon).
 
 	* README, docs/CHANGES: updated for 2.0.5 release
+
 
 2001-10-08  David Turner  <[email protected]>
 
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -171,7 +171,7 @@
   /*         file "ftconfig.h" either statically, or through Autoconf      */
   /*         on platforms that support it.                                 */
   /*                                                                       */
-#define  FT_CONFIG_OPTION_FORCE_INT64
+#undef   FT_CONFIG_OPTION_FORCE_INT64
 
 
   /*************************************************************************/
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -496,11 +496,66 @@
 
   /* documentation is in ftcalc.h */
 
+  /* apparently, the second version of this code is not compiled correctly */
+  /* on Mac machines with the MPW C compiler..  tsss, tsss, tss...         */
+#if 1
   FT_EXPORT_DEF( FT_Int32 )
   FT_Div64by32( FT_Int64*  x,
                 FT_Int32   y )
   {
     FT_Int32   s;
+    FT_UInt32  q, r, i, lo;
+
+
+    s  = x->hi;
+    if ( s < 0 )
+    {
+      x->lo = (FT_UInt32)-(FT_Int32)x->lo;
+      x->hi = ~x->hi + !( x->lo );
+    }
+    s ^= y;  y = ABS( y );
+
+    /* Shortcut */
+    if ( x->hi == 0 )
+    {
+      if ( y > 0 )
+        q = x->lo / y;
+      else
+        q = 0x7FFFFFFFL;
+
+      return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
+    }
+
+    r  = x->hi;
+    lo = x->lo;
+
+    if ( r >= (FT_UInt32)y ) /* we know y is to be treated as unsigned here */
+      return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL );
+                             /* Return Max/Min Int32 if division overflow. */
+                             /* This includes division by zero! */
+    q = 0;
+    for ( i = 0; i < 32; i++ )
+    {
+      r <<= 1;
+      q <<= 1;
+      r  |= lo >> 31;
+
+      if ( r >= (FT_UInt32)y )
+      {
+        r -= y;
+        q |= 1;
+      }
+      lo <<= 1;
+    }
+
+    return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
+  }
+#else
+  FT_EXPORT_DEF( FT_Int32 )
+  FT_Div64by32( FT_Int64*  x,
+                FT_Int32   y )
+  {
+    FT_Int32   s;
     FT_UInt32  q;
 
 
@@ -527,6 +582,7 @@
 
     return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
   }
+#endif
 
 
 #ifdef FT_CONFIG_OPTION_OLD_CALCS