freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master f1458d2: [base] Fix mono bitmap presetting (#53896).


From: Alexei Podtelezhnikov
Subject: [freetype2] master f1458d2: [base] Fix mono bitmap presetting (#53896).
Date: Tue, 15 May 2018 21:48:14 -0400 (EDT)

branch: master
commit f1458d2e44d89e8bc7c0db068f1cbc54b74b9d98
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [base] Fix mono bitmap presetting (#53896).
    
    It is rather fundamental to set monochrome bitmap based on rounded
    CBox because the b/w rasterizer turns on pixels when their centers are
    inside the glyph outline. The dropout control is unpredictable and can
    distort narrow glyphs if the bitmap is too wide.
    
    Reported by Chris Liddell.
    
    * src/base/ftobjs.c (ft_glyphslot_preset_bitmap): If BBox boundaries
    are too close, adjust them before rounding.
---
 ChangeLog         | 14 ++++++++++++++
 src/base/ftobjs.c | 32 +++++++++++++-------------------
 2 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 293bc98..b590def 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2018-05-15  Alexei Podtelezhnikov  <address@hidden>
+
+       [base] Fix mono bitmap presetting (#53896).
+
+       It is rather fundamental to set monochrome bitmap based on rounded
+       CBox because the b/w rasterizer turns on pixels when their centers are
+       inside the glyph outline. The dropout control is unpredictable and can
+       distort narrow glyphs if the bitmap is too wide.
+
+       Reported by Chris Liddell.
+
+       * src/base/ftobjs.c (ft_glyphslot_preset_bitmap): If BBox boundaries
+       are too close, adjust them before rounding.
+
 2018-05-15  Werner Lemberg  <address@hidden>
 
        [psaux] Fix compiler warning (#53915).
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index c102bbe..05e2a03 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -374,32 +374,26 @@
       /* unless the rounded box can collapse for a narrow glyph */
       if ( cbox.xMax - cbox.xMin < 64 )
       {
-        cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
-        cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax );
-      }
-      else
-      {
-        cbox.xMin = FT_PIX_ROUND_LONG( cbox.xMin );
-        cbox.xMax = FT_PIX_ROUND_LONG( cbox.xMax );
+        cbox.xMin = ( cbox.xMin + cbox.xMax ) / 2 - 32;
+        cbox.xMax = cbox.xMin + 64;
       }
 
+      cbox.xMin = FT_PIX_ROUND_LONG( cbox.xMin );
+      cbox.xMax = FT_PIX_ROUND_LONG( cbox.xMax );
+
       if ( cbox.yMax - cbox.yMin < 64 )
       {
-        cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
-        cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax );
-      }
-      else
-      {
-        cbox.yMin = FT_PIX_ROUND_LONG( cbox.yMin );
-        cbox.yMax = FT_PIX_ROUND_LONG( cbox.yMax );
+        cbox.yMin = ( cbox.yMin + cbox.yMax ) / 2 - 32;
+        cbox.yMax = cbox.yMin + 64;
       }
+
+      cbox.yMin = FT_PIX_ROUND_LONG( cbox.yMin );
+      cbox.yMax = FT_PIX_ROUND_LONG( cbox.yMax );
+
+      break;
 #else
-      cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
-      cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
-      cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax );
-      cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax );
+      goto Round;
 #endif
-      break;
 
     case FT_RENDER_MODE_LCD:
       pixel_mode = FT_PIXEL_MODE_LCD;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]