Commit 21bdca7907cb08b3afebe8af808af45456001d3b

Werner Lemberg 2011-01-15T09:46:13

[raster] Make bbox handling the same as with Microsoft's rasterizer. Right before B/W rasterizing, the bbox gets simply rounded to integers. This fixes, for example, glyph `three' in font `Helvetica Neue LT Com 65 Medium' at 11ppem. Thanks to Greg Hitchcock who explained this behaviour. * src/raster/ftrend1.c (ft_raster1_render): Implement it.

diff --git a/ChangeLog b/ChangeLog
index c3dff28..ab0fb40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-01-15  Werner Lemberg  <wl@gnu.org>
+
+	[raster] Make bbox handling the same as with Microsoft's rasterizer.
+
+	Right before B/W rasterizing, the bbox gets simply rounded to
+	integers.  This fixes, for example, glyph `three' in font `Helvetica
+	Neue LT Com 65 Medium' at 11ppem.
+
+	Thanks to Greg Hitchcock who explained this behaviour.
+
+	* src/raster/ftrend1.c (ft_raster1_render): Implement it.
+
 2011-01-15  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
 
 	Copy -mcpu=* & -march=* options from CFLAGS to LDFLAGS.
diff --git a/src/raster/ftrend1.c b/src/raster/ftrend1.c
index 1ed8af6..d8a89f2 100644
--- a/src/raster/ftrend1.c
+++ b/src/raster/ftrend1.c
@@ -161,10 +161,18 @@
     /* compute the control box, and grid fit it */
     FT_Outline_Get_CBox( outline, &cbox );
 
+    /* undocumented but confirmed: bbox values get rounded */
+#if 1
+    cbox.xMin = FT_PIX_ROUND( cbox.xMin );
+    cbox.yMin = FT_PIX_ROUND( cbox.yMin );
+    cbox.xMax = FT_PIX_ROUND( cbox.xMax );
+    cbox.yMax = FT_PIX_ROUND( cbox.yMax );
+#else
     cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
     cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
     cbox.xMax = FT_PIX_CEIL( cbox.xMax );
     cbox.yMax = FT_PIX_CEIL( cbox.yMax );
+#endif
 
     width  = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
     height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );