Commit 91b44e65c2caef02c089b81c6da3181b484f55c5

David Turner 2006-11-02T23:28:09

- improve autofitter's handling of serif fonts (results are much better) - make GCC 4 happy when compiling our zlib sources

diff --git a/ChangeLog b/ChangeLog
index 201f1eb..04f8cac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2006-11-02  David Turner  <david@freetype.org>
 
+	* src/autofit/aflatin.c: adding a few tweaks to better handle
+	serif fonts (we now ignore vertical segments that are less than
+	1 pixels in height, which get rids of *many* corner cases with
+	serifs)
+
 	* src/autofit/afhints.c, src/autofit/afmodule.c,
 	src/autofit/aftypes.h: adding more debug messages and fixing a small
 	bug in af_compute_direction which produced garbage by missing lots of
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 48dc813..9d92db3 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -949,6 +949,7 @@
     AF_Direction  up_dir;
     FT_Fixed      scale;
     FT_Pos        edge_distance_threshold;
+    FT_Pos        segment_length_threshold;
 
 
     axis->num_edges = 0;
@@ -959,6 +960,16 @@
     up_dir = ( dim == AF_DIMENSION_HORZ ) ? AF_DIR_UP
                                           : AF_DIR_RIGHT;
 
+    /* we want to ignore all segments that are less than 1.5
+     * pixels in length, to avoid many problems with serif
+     * fonts. we compute the corresponding threshold in font
+     * units
+     */
+    if ( dim == AF_DIMENSION_VERT )
+        segment_length_threshold = FT_DivFix( 64, hints->y_scale );
+    else
+        segment_length_threshold = 0;
+
     /*********************************************************************/
     /*                                                                   */
     /* We will begin by generating a sorted table of edges for the       */
@@ -988,6 +999,8 @@
       AF_Edge  found = 0;
       FT_Int   ee;
 
+      if ( seg->max_coord - seg->min_coord < segment_length_threshold )
+        continue;
 
       /* look for an edge corresponding to the segment */
       for ( ee = 0; ee < axis->num_edges; ee++ )
@@ -1106,9 +1119,10 @@
 
           /* check for links -- if seg->serif is set, then seg->link must */
           /* be ignored                                                   */
-          is_serif = (FT_Bool)( seg->serif && seg->serif->edge != edge );
+          is_serif = (FT_Bool)( seg->serif && seg->serif->edge &&
+                                seg->serif->edge != edge );
 
-          if ( seg->link || is_serif )
+          if ( (seg->link && seg->link->edge != NULL) || is_serif )
           {
             AF_Edge     edge2;
             AF_Segment  seg2;
@@ -1700,7 +1714,7 @@
       /* this should not happen, but it's better to be safe */
       if ( edge2->blue_edge || edge2 < edge )
       {
-        AF_LOG(( "BLUE: ASSERT FAILED for edge %d\n", edge2-edges ));
+        AF_LOG(( "ASSERT FAILED for edge %d\n", edge2-edges ));
         af_latin_align_linked_edge( hints, dim, edge2, edge );
         edge->flags |= AF_EDGE_DONE;
         continue;
@@ -1774,7 +1788,11 @@
                    (AF_Edge_Flags)edge->flags,
                    (AF_Edge_Flags)edge2->flags );
 
-        if ( cur_len < 96 )
+        if ( edge2->flags & AF_EDGE_DONE )
+        {
+            edge->pos = edge2->pos - cur_len;
+        }
+        else if ( cur_len < 96 )
         {
           FT_Pos  u_off, d_off;
 
diff --git a/src/gzip/inftrees.c b/src/gzip/inftrees.c
index 9002bf5..7b74296 100644
--- a/src/gzip/inftrees.c
+++ b/src/gzip/inftrees.c
@@ -131,6 +131,9 @@ uIntf *v                /* working area: values in order of bit length */
   uInt z;                       /* number of entries in current table */
 
 
+  /* Make comiler happy */
+  r.base = 0;
+
   /* Generate counts for each bit length */
   p = c;
 #define C0 *p++ = 0;