Commit 7774ac67ec562add4212930c82e402a7d7cdff8b

Harsha 2010-12-25T16:34:56

Apply Savannah patch #7422. If we encouter a space in a string then the sbit buffer is NULL, height and width are 0s. So the check in ftc_snode_compare will always pass for spaces (comparision with 255). Here the comments above the condition are proper but the implementation is not. When we create an snode I think it is the proper way to initialize the width to 255 and then put a check for being equal to 255 in snode compare function. * src/cache/ftcsbits.c (FTC_SNode_New): Initialize sbit widths with value 255. (ftc_snode_compare): Fix condition.

diff --git a/ChangeLog b/ChangeLog
index 0c9c1a5..4f16413 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2010-12-25  Harsha  <mm.harsha@gmail.com>
+
+	Apply Savannah patch #7422.
+
+	If we encouter a space in a string then the sbit buffer is NULL,
+	height and width are 0s.  So the check in ftc_snode_compare will
+	always pass for spaces (comparision with 255).  Here the comments
+	above the condition are proper but the implementation is not.  When
+	we create an snode I think it is the proper way to initialize the
+	width to 255 and then put a check for being equal to 255 in snode
+	compare function.
+
+	* src/cache/ftcsbits.c (FTC_SNode_New): Initialize sbit widths with
+	value 255.
+	(ftc_snode_compare): Fix condition.
+
 2010-12-13  Werner Lemberg  <wl@gnu.org>
 
 	Fix parameter handling of `FT_Set_Renderer'.
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 83245af..0386bdd 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -217,6 +217,7 @@
 
     FTC_SFamilyClass  clazz = FTC_CACHE__SFAMILY_CLASS( cache );
     FT_UInt           total;
+    FT_UInt           node_count;
 
 
     total = clazz->family_get_count( family, cache->manager );
@@ -239,6 +240,10 @@
       FTC_GNode_Init( FTC_GNODE( snode ), start, family );
 
       snode->count = count;
+      for ( node_count = 0; node_count < count; node_count++ )
+      {
+        snode->sbits[node_count].width = 255;
+      }
 
       error = ftc_snode_load( snode,
                               cache->manager,
@@ -368,7 +373,7 @@
        *
        */
 
-      if ( sbit->buffer == NULL && sbit->width != 255 )
+      if ( sbit->buffer == NULL && sbit->width == 255 )
       {
         FT_ULong  size;
         FT_Error  error;