[base] Improve kerning tracing and documentation. * src/base/ftobjs.c (FT_Get_Kerning): Emit tracing message if scaled-down kerning values differ.
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
diff --git a/ChangeLog b/ChangeLog
index 2fa7140..49db8b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-08-25 Werner Lemberg <wl@gnu.org>
+
+ [base] Improve kerning tracing and documentation.
+
+ * src/base/ftobjs.c (FT_Get_Kerning): Emit tracing message if
+ scaled-down kerning values differ.
+
2015-08-18 Werner Lemberg <wl@gnu.org>
[raster] Remove last remnants of `raster5' driver.
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index f3a9d6f..61b6a45 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -3041,6 +3041,11 @@ FT_BEGIN_HEADER
/* FT_KERNING_UNSCALED :: Return the kerning vector in original font */
/* units. */
/* */
+ /* <Note> */
+ /* FT_KERNING_DEFAULT returns full pixel values; it also makes */
+ /* FreeType heuristically scale down kerning distances at small ppem */
+ /* values so that they don't become too big. */
+ /* */
typedef enum FT_Kerning_Mode_
{
FT_KERNING_DEFAULT = 0,
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 926ac0a..7092856 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -3073,18 +3073,37 @@
if ( kern_mode != FT_KERNING_UNFITTED )
{
+ FT_Pos orig_x = akerning->x;
+ FT_Pos orig_y = 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,
+ akerning->x = FT_MulDiv( orig_x,
face->size->metrics.x_ppem, 25 );
if ( face->size->metrics.y_ppem < 25 )
- akerning->y = FT_MulDiv( akerning->y,
+ akerning->y = FT_MulDiv( orig_y,
face->size->metrics.y_ppem, 25 );
akerning->x = FT_PIX_ROUND( akerning->x );
akerning->y = FT_PIX_ROUND( akerning->y );
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ FT_Pos orig_x_rounded = FT_PIX_ROUND( orig_x );
+ FT_Pos orig_y_rounded = FT_PIX_ROUND( orig_y );
+
+
+ if ( akerning->x != orig_x_rounded ||
+ akerning->y != orig_y_rounded )
+ FT_TRACE5(( "FT_Get_Kerning: horizontal kerning"
+ " (%d, %d) scaled down to (%d, %d) pixels\n",
+ orig_x_rounded / 64, orig_y_rounded / 64,
+ akerning->x / 64, akerning->y / 64 ));
+ }
+#endif
}
}
}