Commit db8df797d088e2e861bafb81dedb4106f15523be

Werner Lemberg 2015-04-01T13:30:55

[autofit] Make debugging stuff work again. The interface to ftgrid was broken in the series of commits starting with [autofit] Allocate AF_Loader on the stack instead of AF_Module. from 2015-01-14. * src/autofit/afmodule.c (_af_debug_hints_rec) [FT_DEBUG_AUTOFIT]: Use a global AF_GlyphHintsRec object for debugging. (af_autofitter_done, af_autofitter_load_glyph): Updated. * src/autofit/afloader.c (af_loader_init, af_loader_done): Updated.

diff --git a/ChangeLog b/ChangeLog
index 97bf293..6693943 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2015-04-01  Werner Lemberg  <wl@gnu.org>
 
+	[autofit] Make debugging stuff work again.
+
+	The interface to ftgrid was broken in the series of commits starting
+	with
+
+	  [autofit] Allocate AF_Loader on the stack instead of AF_Module.
+
+	from 2015-01-14.
+
+	* src/autofit/afmodule.c (_af_debug_hints_rec) [FT_DEBUG_AUTOFIT]:
+	Use a global AF_GlyphHintsRec object for debugging.
+	(af_autofitter_done, af_autofitter_load_glyph): Updated.
+
+	* src/autofit/afloader.c (af_loader_init, af_loader_done): Updated.
+
+2015-04-01  Werner Lemberg  <wl@gnu.org>
+
 	* src/autofit/afhints.c (af_glyph_hints_done): Fix minor thinko.
 
 2015-03-29  Werner Lemberg  <wl@gnu.org>
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index 5f68c8c..7c2fa7c 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -33,9 +33,6 @@
     FT_ZERO( loader );
 
     loader->hints = hints;
-#ifdef FT_DEBUG_AUTOFIT
-    _af_debug_hints = loader->hints;
-#endif
   }
 
 
@@ -76,10 +73,6 @@
     loader->face    = NULL;
     loader->globals = NULL;
     loader->hints   = NULL;
-
-#ifdef FT_DEBUG_AUTOFIT
-    _af_debug_hints = NULL;
-#endif
   }
 
 
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index 35ce6ad..4968e01 100644
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -23,10 +23,14 @@
 #include "afpic.h"
 
 #ifdef FT_DEBUG_AUTOFIT
-  int    _af_debug_disable_horz_hints;
-  int    _af_debug_disable_vert_hints;
-  int    _af_debug_disable_blue_hints;
-  void*  _af_debug_hints;
+  int  _af_debug_disable_horz_hints;
+  int  _af_debug_disable_vert_hints;
+  int  _af_debug_disable_blue_hints;
+
+  /* we use a global object instead of a local one for debugging */
+  AF_GlyphHintsRec  _af_debug_hints_rec[1];
+
+  void*  _af_debug_hints = _af_debug_hints_rec;
 #endif
 
 #include FT_INTERNAL_OBJECTS_H
@@ -261,6 +265,11 @@
   af_autofitter_done( FT_Module  ft_module )      /* AF_Module */
   {
     FT_UNUSED( ft_module );
+
+#ifdef FT_DEBUG_AUTOFIT
+    if ( _af_debug_hints_rec->memory )
+      af_glyph_hints_done( _af_debug_hints_rec );
+#endif
   }
 
 
@@ -274,6 +283,31 @@
     FT_Error   error  = FT_Err_Ok;
     FT_Memory  memory = module->root.library->memory;
 
+#ifdef FT_DEBUG_AUTOFIT
+
+    /* in debug mode, we use a global object that survives this routine */
+
+    AF_GlyphHints  hints = _af_debug_hints_rec;
+    AF_LoaderRec   loader[1];
+
+    FT_UNUSED( size );
+
+
+    if ( hints->memory )
+      af_glyph_hints_done( hints );
+
+    af_glyph_hints_init( hints, memory );
+    af_loader_init( loader, hints );
+
+    error = af_loader_load_glyph( loader, module, slot->face,
+                                  glyph_index, load_flags );
+
+    af_loader_done( loader );
+
+    return error;
+
+#else /* !FT_DEBUG_AUTOFIT */
+
     AF_GlyphHintsRec  hints[1];
     AF_LoaderRec      loader[1];
 
@@ -290,6 +324,8 @@
     af_glyph_hints_done( hints );
 
     return error;
+
+#endif /* !FT_DEBUG_AUTOFIT */
   }