shithub: freetype+ttf2subf

Download patch

ref: ca980b4cf11405469a5b5919dc40e73c4961c7c7
parent: 35efb103fee44fcacb657e1dc5896e32ac99d295
author: Alexei Podtelezhnikov <[email protected]>
date: Thu Aug 30 17:51:18 EDT 2018

* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Correct mono.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-08-30  Alexei Podtelezhnikov  <[email protected]>
+
+	* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Correct mono.
+
 2018-08-30  Armin Hasitzka  <[email protected]>
 
 	[errors] Introduce a macro to control `FT_Error_String'.
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -391,25 +391,31 @@
       pixel_mode = FT_PIXEL_MODE_MONO;
 #if 1
       /* undocumented but confirmed: bbox values get rounded    */
-      /* unless the rounded box can collapse for a narrow glyph */
-      if ( pbox.xMax - pbox.xMin == 0 )
+      /* for narrow glyphs bbox is extended to one pixel first  */
+      if ( pbox.xMax - pbox.xMin <= 1 )
       {
-        cbox.xMin = ( cbox.xMin + cbox.xMax ) / 2 - 32;
-        cbox.xMax = cbox.xMin + 64;
+        if ( pbox.xMax - pbox.xMin == 0 )
+        {
+          cbox.xMin = ( cbox.xMin + cbox.xMax ) / 2 - 32;
+          cbox.xMax = cbox.xMin + 64;
+        }
+        else if ( cbox.xMax - cbox.xMin < 0 )
+          cbox.xMin = cbox.xMax = ( cbox.xMin + cbox.xMax ) / 2;
       }
-      else if ( pbox.xMax - pbox.xMin == 1 )
-        cbox.xMin = cbox.xMax = ( cbox.xMin + cbox.xMax ) / 2;
 
       pbox.xMin += ( cbox.xMin + 32 ) >> 6;
       pbox.xMax += ( cbox.xMax + 32 ) >> 6;
 
-      if ( pbox.yMax - pbox.yMin == 0 )
+      if ( pbox.yMax - pbox.yMin <= 1 )
       {
-        cbox.yMin = ( cbox.yMin + cbox.yMax ) / 2 - 32;
-        cbox.yMax = cbox.yMin + 64;
+        if ( pbox.yMax - pbox.yMin == 0 )
+        {
+          cbox.yMin = ( cbox.yMin + cbox.yMax ) / 2 - 32;
+          cbox.yMax = cbox.yMin + 64;
+        }
+        else if ( cbox.yMax - cbox.yMin < 0 )
+          cbox.yMin = cbox.yMax = ( cbox.yMin + cbox.yMax ) / 2;
       }
-      else if ( pbox.yMax - pbox.yMin == 1 )
-        cbox.yMin = cbox.yMax = ( cbox.yMin + cbox.yMax ) / 2;
 
       pbox.yMin += ( cbox.yMin + 32 ) >> 6;
       pbox.yMax += ( cbox.yMax + 32 ) >> 6;