Commit 133eee06bf52ae10054cce2dfa8ff40a6c15470b

Werner Lemberg 2004-12-12T06:55:40

* src/base/ftobjs.c (FT_Get_Kerning): Make kerning amount dependent on ppem by scaling down for ppem < 25, then do normal rounding. This gives slightly better results than rounding towards zero.

diff --git a/ChangeLog b/ChangeLog
index a247f87..5274c64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-12-11  Robert Clark  <freetype@ratty.org.uk>
+
+	* src/base/ftobjs.c (FT_Get_Kerning): Make kerning amount
+	dependent on ppem by scaling down for ppem < 25, then do normal
+	rounding.  This gives slightly better results than rounding towards
+	zero.
+
 2004-12-09  Werner Lemberg  <wl@gnu.org>
 
 	* src/base/ftobjs.c (FT_Get_Kerning): Always round towards zero
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 31a7bff..58b0711 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2137,10 +2137,18 @@
 
           if ( kern_mode != FT_KERNING_UNFITTED )
           {
-            akerning->x = akerning->x > 0 ? FT_PIX_FLOOR( akerning->x )
-                                          : FT_PIX_CEIL( akerning->x );
-            akerning->y = akerning->y > 0 ? FT_PIX_FLOOR( akerning->y )
-                                          : FT_PIX_CEIL( akerning->y );
+            /* we scale down kerning values for small ppem values */
+            /* to avoid that rounding makes them too big.         */
+            /* `25' has been determined heuristically.            */
+            if ( face->size->metrics.x_ppem < 25 )
+              akerning->x = FT_MulDiv( akerning->x,
+                                       face->size->metrics.x_ppem, 25 );
+            if ( face->size->metrics.y_ppem < 25 )
+              akerning->y = FT_MulDiv( akerning->y,
+                                       face->size->metrics.y_ppem, 25 );
+
+            akerning->x = FT_PIX_ROUND( akerning->x );
+            akerning->y = FT_PIX_ROUND( akerning->y );
           }
         }
       }
diff --git a/src/otvalid/otvcommn.h b/src/otvalid/otvcommn.h
index fa93e5a..4c78d3f 100644
--- a/src/otvalid/otvcommn.h
+++ b/src/otvalid/otvcommn.h
@@ -67,7 +67,7 @@ FT_BEGIN_HEADER
 
 
 #undef  FT_INVALID_
-#define FT_INVALID_( _prefix, _error ) \
+#define FT_INVALID_( _prefix, _error )                         \
           ft_validator_error( valid->root, _prefix ## _error )
 
 #define OTV_OPTIONAL_TABLE( _table )  FT_UInt   _table;      \
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index cff40e5..ea48bde 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -1436,7 +1436,7 @@
     error = face->goto_table( face, TTAG_EBDT, stream, 0 );
     if ( error )
       error = face->goto_table( face, TTAG_bdat, stream, 0 );
-    if (error)
+    if ( error )
       goto Exit;
 
     ebdt_pos = FT_STREAM_POS();