shithub: freetype+ttf2subf

Download patch

ref: 406047481513a215fbd5d631cb2baff836148334
parent: 950c5d2f074e31e77b4ec3bb2b673e6adae263b1
author: David Turner <[email protected]>
date: Thu Nov 2 11:37:35 EST 2006

- fixed a bug in af_compute_direction which generated ugly glyphs
- added more debug/log messages to help improve the auto-fitter

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-11-02  David Turner  <[email protected]>
+
+	* 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
+	segments
+
 2006-10-24  Werner Lemberg  <[email protected]>
 
 	* src/cff/cffload.c (cff_encoding_load): Remove unused variable.
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -311,7 +311,7 @@
     }
 
     ss *= 12;
-    if ( ll <= FT_ABS( ss ) )
+    if ( FT_ABS(ll) <= FT_ABS(ss) )
       dir = AF_DIR_NONE;
 
     return dir;
--- a/src/autofit/afhints.h
+++ b/src/autofit/afhints.h
@@ -227,6 +227,8 @@
 #define AF_HINTS_DO_ADVANCE( h )                                \
           !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
 
+#define AF_HINTS_DO_BLUES( h )    ( !_af_debug_disable_blue_hints )
+
 #else /* !AF_DEBUG */
 
 #define AF_HINTS_DO_HORIZONTAL( h )                                \
@@ -237,6 +239,8 @@
 
 #define AF_HINTS_DO_ADVANCE( h )                                \
           !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
+
+#define AF_HINTS_DO_BLUES( h )   1
 
 #endif /* !AF_DEBUG */
 
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -1586,8 +1586,11 @@
                              (AF_Edge_Flags)base_edge->flags,
                              (AF_Edge_Flags)stem_edge->flags );
 
-
     stem_edge->pos = base_edge->pos + fitted_width;
+
+    AF_LOG(( "LINK: edge %d (opos=%.2f) linked to (%.2f), dist was %.2f now %.2f\n",
+             stem_edge-hints->axis[dim].edges, stem_edge->opos/64.0,
+             stem_edge->pos/64.0, dist/64., fitted_width/64. ));
   }
 
 
@@ -1629,7 +1632,7 @@
     /* we begin by aligning all stems relative to the blue zone */
     /* if needed -- that's only for horizontal edges            */
 
-    if ( dim == AF_DIMENSION_VERT )
+    if ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_BLUES(hints) )
     {
       for ( edge = edges; edge < edge_limit; edge++ )
       {
@@ -1658,6 +1661,8 @@
         if ( !edge1 )
           continue;
 
+        AF_LOG(( "BLUE: edge %d (opos=%.2f) snapped to (%.2f) was (%.2f)\n",
+                 edge1-edges, edge1->opos/64., blue->fit/64., edge1->pos/64.0 ));
         edge1->pos    = blue->fit;
         edge1->flags |= AF_EDGE_DONE;
 
@@ -1695,6 +1700,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_latin_align_linked_edge( hints, dim, edge2, edge );
         edge->flags |= AF_EDGE_DONE;
         continue;
@@ -1745,6 +1751,8 @@
         else
           edge->pos = FT_PIX_ROUND( edge->opos );
 
+        AF_LOG(( "ANCHOR: edge %d (opos=%.2f) snapped to (%.2f)\n",
+                 edge-edges, edge->opos/64., edge->pos/64. ));
         anchor = edge;
 
         edge->flags |= AF_EDGE_DONE;
@@ -1796,6 +1804,9 @@
 
           edge->pos  = cur_pos1 - cur_len / 2;
           edge2->pos = cur_pos1 + cur_len / 2;
+          AF_LOG(( "STEM: %d (opos=%.2f) to %d (opos=%.2f) snapped to (%.2f) and (%.2f)\n",
+                   edge-edges, edge->opos/64., edge2-edges, edge2->opos/64.,
+                   edge->pos/64., edge2->pos/64. ));
         }
         else
         {
@@ -1820,6 +1831,10 @@
 
           edge->pos  = ( delta1 < delta2 ) ? cur_pos1 : cur_pos2;
           edge2->pos = edge->pos + cur_len;
+
+          AF_LOG(( "STEM: %d (opos=%.2f) to %d (opos=%.2f) snapped to (%.2f) and (%.2f)\n",
+                   edge-edges, edge->opos/64., edge2-edges, edge2->opos/64.,
+                   edge->pos/64., edge2->pos/64. ));
         }
 
         edge->flags  |= AF_EDGE_DONE;
@@ -1826,7 +1841,11 @@
         edge2->flags |= AF_EDGE_DONE;
 
         if ( edge > edges && edge->pos < edge[-1].pos )
+        {
+          AF_LOG(( "BOUND: %d (pos=%.2f) to (%.2f)\n", edge-edges,
+                   edge->pos/64., edge[-1].pos/64. ));
           edge->pos = edge[-1].pos;
+        }
       }
     }
 
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -30,7 +30,9 @@
     FT_ZERO( loader );
 
     af_glyph_hints_init( &loader->hints, memory );
-
+#ifdef AF_DEBUG
+    _af_debug_hints = &loader->hints;
+#endif
     return FT_GlyphLoader_New( memory, &loader->gloader );
   }
 
@@ -71,6 +73,9 @@
     loader->face    = NULL;
     loader->globals = NULL;
 
+#ifdef AF_DEBUG
+    _af_debug_hints = NULL;
+#endif
     FT_GlyphLoader_Done( loader->gloader );
     loader->gloader = NULL;
   }
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -22,6 +22,8 @@
 #ifdef AF_DEBUG
   int  _af_debug_disable_horz_hints;
   int  _af_debug_disable_vert_hints;
+  int  _af_debug_disable_blue_hints;
+  void*  _af_debug_hints;
 #endif
 
 #include FT_INTERNAL_OBJECTS_H
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -63,6 +63,8 @@
 
 extern int  _af_debug_disable_horz_hints;
 extern int  _af_debug_disable_vert_hints;
+extern int  _af_debug_disable_blue_hints;
+extern void*  _af_debug_hints;
 
 #else /* !AF_DEBUG */