freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] Any tool that visually present segments of autofit module?


From: JustFillBug
Subject: [ft-devel] Any tool that visually present segments of autofit module?
Date: Thu, 6 Jan 2011 13:56:52 +0000 (UTC)
User-agent: slrn/pre1.0.0-18 (Linux)

Are there any tool which visually present segments of autofit module?
Something like stems shown in the glyph view of fontforge.

It seems that ftgrid can dump autofit segment data to the terminal. But
it's awkward to use with no label on the axis. Besides, that function
was broken. I attached a patch to re-enable the function.

The ftgrid binary need to be recompiled against a freetype lib with
AF_DEBUG defined. I see no benefit of this forced recompilation other
than a slightly less symbol pollution.

diff --git a/src/ftgrid.c b/src/ftgrid.c
index 75cd6ce..64ea0a3 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -42,6 +42,8 @@
 
 /* these variables, structures and declarations  are for  */
 /* communication with the debugger in the autofit module; */
+/* To make it work, AF_DEBUG need to be defined in        */
+/* freetype.                                              */
 /* normal programs don't need this                        */
 struct  AF_GlyphHintsRec_;
 typedef struct AF_GlyphHintsRec_*  AF_GlyphHints;
@@ -640,6 +642,50 @@ grid_status_draw_outline( GridStatus       st,
       status.Num = num_indices - 1;
   }
 
+  typedef enum
+  {
+    af_edge,
+    af_segment,
+    af_point
+  } AFDumpType;
+
+
+  static void 
+  dump_af_data(GridStatus       st,
+               FTDemo_Handle*   hd,
+               AFDumpType       atype )
+  {
+    FT_Size  size;
+    int      old_do_hint = hd->hinted;
+    int      old_do_autohint = hd->autohint;
+
+    /* Need to turn on hint and autohint for autofit data. */
+    hd->hinted = 1;
+    hd->autohint = 1;
+    FTDemo_Update_Current_Flags( hd );
+    FTDemo_Get_Size( hd, &size );
+
+    if ( !FT_Load_Glyph( size->face, st->Num,
+         hd->load_flags | FT_LOAD_NO_BITMAP ) )
+    {
+      switch (atype)
+      {
+       case af_edge:
+         af_glyph_hints_dump_edges( _af_debug_hints );
+         break;
+       case af_segment:
+         af_glyph_hints_dump_segments( _af_debug_hints );
+         break;
+       case af_point:
+         af_glyph_hints_dump_points( _af_debug_hints );
+         break;
+      }
+    }
+
+    hd->hinted = old_do_hint;
+    hd->autohint = old_do_autohint;
+    FTDemo_Update_Current_Flags( hd );
+  }
 
   static int
   Process_Event( grEvent*  event )
@@ -669,15 +715,15 @@ grid_status_draw_outline( GridStatus       st,
       break;
 
     case grKEY( '1' ):
-      af_glyph_hints_dump_edges( _af_debug_hints );
+      dump_af_data(&status, handle, af_edge);
       break;
 
     case grKEY( '2' ):
-      af_glyph_hints_dump_segments( _af_debug_hints );
+      dump_af_data(&status, handle, af_segment);
       break;
 
     case grKEY( '3' ):
-      af_glyph_hints_dump_points( _af_debug_hints );
+      dump_af_data(&status, handle, af_point);
       break;
 
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]