[HarfBuzz] harfbuzz: Branch 'master' - 2 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Jul 19 02:16:48 UTC 2017


 src/hb-ot-shape-complex-indic.cc |    2 +-
 util/hb-ot-shape-closure.cc      |   10 +++++++---
 util/hb-shape.cc                 |   33 +++++++++++++++++++++++++++++++--
 util/main-font-text.hh           |   27 ++++-----------------------
 util/options.cc                  |   10 +++++++---
 util/options.hh                  |    2 ++
 util/shape-consumer.hh           |   18 ++++++++++++------
 util/view-cairo.hh               |    4 ++--
 8 files changed, 66 insertions(+), 40 deletions(-)

New commits:
commit e60350551addbd945491f662e98464c9e3e9fec5
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jul 18 19:14:19 2017 -0700

    [hb-shape] Improve shaping-debug output
    
    Before, that was printed using --debug (and in both hb-shape and hb-view).
    Changed it, now hb-shape has a new command-line argument called --show-messages.
    When invoked, it also respects other output formatting options.  The messages
    are better formatted and printed to te same place that hb-shape output is
    directed to.  Previously they were written to stderr.
    
    Fixes https://github.com/behdad/harfbuzz/issues/506

diff --git a/util/hb-ot-shape-closure.cc b/util/hb-ot-shape-closure.cc
index 859f9a60..be71a893 100644
--- a/util/hb-ot-shape-closure.cc
+++ b/util/hb-ot-shape-closure.cc
@@ -53,14 +53,15 @@ struct shape_closure_consumer_t : option_group_t
 		       this);
   }
 
-  void init (const font_options_t *font_opts)
+  void init (hb_buffer_t  *buffer_,
+	     const font_options_t *font_opts)
   {
     glyphs = hb_set_create ();
     font = hb_font_reference (font_opts->get_font ());
     failed = false;
+    buffer = hb_buffer_reference (buffer_);
   }
-  void consume_line (hb_buffer_t  *buffer,
-		     const char   *text,
+  void consume_line (const char   *text,
 		     unsigned int  text_len,
 		     const char   *text_before,
 		     const char   *text_after)
@@ -95,6 +96,8 @@ struct shape_closure_consumer_t : option_group_t
     font = NULL;
     hb_set_destroy (glyphs);
     glyphs = NULL;
+    hb_buffer_destroy (buffer);
+    buffer = NULL;
   }
 
   bool failed;
@@ -105,6 +108,7 @@ struct shape_closure_consumer_t : option_group_t
 
   hb_set_t *glyphs;
   hb_font_t *font;
+  hb_buffer_t *buffer;
 };
 
 int
diff --git a/util/hb-shape.cc b/util/hb-shape.cc
index 75c3793b..88584316 100644
--- a/util/hb-shape.cc
+++ b/util/hb-shape.cc
@@ -39,7 +39,7 @@ struct output_buffer_t
 		    output_format (HB_BUFFER_SERIALIZE_FORMAT_INVALID),
 		    format_flags (HB_BUFFER_SERIALIZE_FLAG_DEFAULT) {}
 
-  void init (const font_options_t *font_opts)
+  void init (hb_buffer_t *buffer, const font_options_t *font_opts)
   {
     options.get_file_handle ();
     gs = g_string_new (NULL);
@@ -75,6 +75,9 @@ struct output_buffer_t
     if (format.show_extents)
       flags |= HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS;
     format_flags = (hb_buffer_serialize_flags_t) flags;
+
+    if (format.show_messages)
+      hb_buffer_set_message_func (buffer, message_func, this, NULL);
   }
   void new_line (void)
   {
@@ -108,14 +111,40 @@ struct output_buffer_t
 				       output_format, format_flags, gs);
     fprintf (options.fp, "%s", gs->str);
   }
-  void finish (const font_options_t *font_opts)
+  void finish (hb_buffer_t *buffer, const font_options_t *font_opts)
   {
+    hb_buffer_set_message_func (buffer, NULL, NULL, NULL);
     hb_font_destroy (font);
     g_string_free (gs, true);
     gs = NULL;
     font = NULL;
   }
 
+  static hb_bool_t
+  message_func (hb_buffer_t *buffer,
+		hb_font_t *font,
+		const char *message,
+		void *user_data)
+  {
+    output_buffer_t *that = (output_buffer_t *) user_data;
+    that->message (buffer, font, message);
+    return true;
+  }
+
+  void
+  message (hb_buffer_t *buffer,
+	   hb_font_t *font,
+	   const char *message)
+  {
+    g_string_set_size (gs, 0);
+    format.serialize_line_no (line_no, gs);
+    g_string_append_printf (gs, "HB: %s	buffer: ", message);
+    format.serialize_glyphs (buffer, font, output_format, format_flags, gs);
+    g_string_append_c (gs, '\n');
+    fprintf (options.fp, "%s", gs->str);
+  }
+
+
   protected:
   output_options_t options;
   format_options_t format;
diff --git a/util/main-font-text.hh b/util/main-font-text.hh
index 55de5676..51f16278 100644
--- a/util/main-font-text.hh
+++ b/util/main-font-text.hh
@@ -46,23 +46,6 @@ locale_to_utf8 (char *s)
   return t;
 }
 
-static hb_bool_t
-message_func (hb_buffer_t *buffer,
-	      hb_font_t *font,
-	      const char *message,
-	      void *user_data)
-{
-  fprintf (stderr, "HB: %s\n", message);
-  char buf[4096];
-  hb_buffer_serialize_glyphs (buffer, 0, hb_buffer_get_length (buffer),
-			      buf, sizeof (buf), NULL,
-			      font,
-			      HB_BUFFER_SERIALIZE_FORMAT_TEXT,
-			      HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
-  fprintf (stderr, "HB: buffer [%s]\n", buf);
-  return true;
-}
-
 template <typename consumer_t, int default_font_size, int subpixel_bits>
 struct main_font_text_t
 {
@@ -87,16 +70,14 @@ struct main_font_text_t
     if (!input.text && !input.text_file)
       input.text_file = g_strdup ("-");
 
-    consumer.init (&font_opts);
-
     hb_buffer_t *buffer = hb_buffer_create ();
-    if (debug)
-      hb_buffer_set_message_func (buffer, message_func, NULL, NULL);
+    consumer.init (buffer, &font_opts);
+    hb_buffer_destroy (buffer);
+
     unsigned int text_len;
     const char *text;
     while ((text = input.get_line (&text_len)))
-      consumer.consume_line (buffer, text, text_len, input.text_before, input.text_after);
-    hb_buffer_destroy (buffer);
+      consumer.consume_line (text, text_len, input.text_before, input.text_after);
 
     consumer.finish (&font_opts);
 
diff --git a/util/options.cc b/util/options.cc
index 0f2e207d..ee749640 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -777,6 +777,7 @@ format_options_t::add_options (option_parser_t *parser)
     {"no-clusters",	0, G_OPTION_FLAG_REVERSE,
 			      G_OPTION_ARG_NONE,	&this->show_clusters,		"Do not output cluster indices",					NULL},
     {"show-extents",	0, 0, G_OPTION_ARG_NONE,	&this->show_extents,		"Output glyph extents",							NULL},
+    {"show-messages",	0, 0, G_OPTION_ARG_NONE,	&this->show_messages,		"Output shaping debug messages",					NULL},
     {NULL}
   };
   parser->add_group (entries,
@@ -818,7 +819,8 @@ format_options_t::serialize_glyphs (hb_buffer_t *buffer,
   unsigned int num_glyphs = hb_buffer_get_length (buffer);
   unsigned int start = 0;
 
-  while (start < num_glyphs) {
+  while (start < num_glyphs)
+  {
     char buf[1024];
     unsigned int consumed;
     start += hb_buffer_serialize_glyphs (buffer, start, num_glyphs,
@@ -845,7 +847,8 @@ format_options_t::serialize_buffer_of_text (hb_buffer_t  *buffer,
 					    hb_font_t    *font,
 					    GString      *gs)
 {
-  if (show_text) {
+  if (show_text)
+  {
     serialize_line_no (line_no, gs);
     g_string_append_c (gs, '(');
     g_string_append_len (gs, text, text_len);
@@ -853,7 +856,8 @@ format_options_t::serialize_buffer_of_text (hb_buffer_t  *buffer,
     g_string_append_c (gs, '\n');
   }
 
-  if (show_unicode) {
+  if (show_unicode)
+  {
     serialize_line_no (line_no, gs);
     serialize_unicode (buffer, gs);
     g_string_append_c (gs, '\n');
diff --git a/util/options.hh b/util/options.hh
index 9ed4fd0e..ff6a61ba 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -437,6 +437,7 @@ struct format_options_t : option_group_t
     show_unicode = false;
     show_line_num = false;
     show_extents = false;
+    show_messages = false;
 
     add_options (parser);
   }
@@ -478,6 +479,7 @@ struct format_options_t : option_group_t
   hb_bool_t show_unicode;
   hb_bool_t show_line_num;
   hb_bool_t show_extents;
+  hb_bool_t show_messages;
 };
 
 /* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */
diff --git a/util/shape-consumer.hh b/util/shape-consumer.hh
index 422c8cdc..78492428 100644
--- a/util/shape-consumer.hh
+++ b/util/shape-consumer.hh
@@ -39,14 +39,16 @@ struct shape_consumer_t
 		    output (parser),
 		    font (NULL) {}
 
-  void init (const font_options_t *font_opts)
+  void init (hb_buffer_t  *buffer_,
+	     const font_options_t *font_opts)
   {
     font = hb_font_reference (font_opts->get_font ());
-    output.init (font_opts);
     failed = false;
+    buffer = hb_buffer_reference (buffer_);
+
+    output.init (buffer, font_opts);
   }
-  void consume_line (hb_buffer_t  *buffer,
-		     const char   *text,
+  void consume_line (const char   *text,
 		     unsigned int  text_len,
 		     const char   *text_before,
 		     const char   *text_after)
@@ -58,7 +60,8 @@ struct shape_consumer_t
       shaper.populate_buffer (buffer, text, text_len, text_before, text_after);
       if (n == 1)
 	output.consume_text (buffer, text, text_len, shaper.utf8_clusters);
-      if (!shaper.shape (font, buffer)) {
+      if (!shaper.shape (font, buffer))
+      {
 	failed = true;
 	hb_buffer_set_length (buffer, 0);
 	output.shape_failed (buffer, text, text_len, shaper.utf8_clusters);
@@ -70,9 +73,11 @@ struct shape_consumer_t
   }
   void finish (const font_options_t *font_opts)
   {
-    output.finish (font_opts);
+    output.finish (buffer, font_opts);
     hb_font_destroy (font);
     font = NULL;
+    hb_buffer_destroy (buffer);
+    buffer = NULL;
   }
 
   public:
@@ -83,6 +88,7 @@ struct shape_consumer_t
   output_t output;
 
   hb_font_t *font;
+  hb_buffer_t *buffer;
 };
 
 
diff --git a/util/view-cairo.hh b/util/view-cairo.hh
index f55d4bb4..ef229ff7 100644
--- a/util/view-cairo.hh
+++ b/util/view-cairo.hh
@@ -43,7 +43,7 @@ struct view_cairo_t
       cairo_debug_reset_static_data ();
   }
 
-  void init (const font_options_t *font_opts)
+  void init (hb_buffer_t *buffer, const font_options_t *font_opts)
   {
     lines = g_array_new (false, false, sizeof (helper_cairo_line_t));
     scale_bits = -font_opts->subpixel_bits;
@@ -74,7 +74,7 @@ struct view_cairo_t
     helper_cairo_line_from_buffer (&l, buffer, text, text_len, scale_bits, utf8_clusters);
     g_array_append_val (lines, l);
   }
-  void finish (const font_options_t *font_opts)
+  void finish (hb_buffer_t *buffer, const font_options_t *font_opts)
   {
     render (font_opts);
 
commit 65f64d14005e4d0808e818b3c97bd3d600628011
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Wed Jul 19 02:42:53 2017 +0430

    Unbreak arm-none-eabi build again (#514)

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 0232b305..02aab082 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -200,7 +200,7 @@ set_indic_properties (hb_glyph_info_t &info)
     cat = OT_Symbol;
     ASSERT_STATIC ((int) INDIC_SYLLABIC_CATEGORY_AVAGRAHA == OT_Symbol);
   }
-  else if (unlikely (hb_in_range (u, 0x17CDu, 0x17D1u) ||
+  else if (unlikely (hb_in_range<hb_codepoint_t> (u, 0x17CDu, 0x17D1u) ||
 		     u == 0x17CBu || u == 0x17D3u || u == 0x17DDu)) /* Khmer Various signs */
   {
     /* These can occur mid-syllable (eg. before matras), even though Unicode marks them as Syllable_Modifier.


More information about the HarfBuzz mailing list