src/hb-ot-shape-complex-arabic.cc |    2 +-
 src/hb-utf-private.hh             |    4 ++--
 util/hb-ot-shape-closure.cc       |    4 +++-
 util/main-font-text.hh            |    2 +-
 util/options.cc                   |    2 ++
 util/options.hh                   |   18 ++++++++++++++++--
 util/shape-consumer.hh            |    6 ++++--
 7 files changed, 29 insertions(+), 9 deletions(-)

New commits:
commit 321f73c16efa0730c96e001d65268f4927a0f735
Author: Behdad Esfahbod <[email protected]>
Date:   Tue Nov 13 15:12:24 2012 -0800

    [util] Add --text-before and --text-after to hb-shape / hb-view
    
    Use with Arabic, for example, to see the effect on joining.

diff --git a/util/hb-ot-shape-closure.cc b/util/hb-ot-shape-closure.cc
index 6dce7a1..2289605 100644
--- a/util/hb-ot-shape-closure.cc
+++ b/util/hb-ot-shape-closure.cc
@@ -61,7 +61,9 @@ struct shape_closure_consumer_t : option_group_t
   }
   void consume_line (hb_buffer_t  *buffer,
                     const char   *text,
-                    unsigned int  text_len)
+                    unsigned int  text_len,
+                    const char   *text_before,
+                    const char   *text_after)
   {
     hb_set_clear (glyphs);
     shaper.shape_closure (text, text_len, font, buffer, glyphs);
diff --git a/util/main-font-text.hh b/util/main-font-text.hh
index 44e3bfb..ac51b2d 100644
--- a/util/main-font-text.hh
+++ b/util/main-font-text.hh
@@ -61,7 +61,7 @@ struct main_font_text_t
     unsigned int text_len;
     const char *text;
     while ((text = input.get_line (&text_len)))
-      consumer.consume_line (buffer, text, text_len);
+      consumer.consume_line (buffer, text, text_len, input.text_before, 
input.text_after);
     hb_buffer_destroy (buffer);
 
     consumer.finish (&font_opts);
diff --git a/util/options.cc b/util/options.cc
index 1f626b6..ef07e9f 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -350,6 +350,8 @@ text_options_t::add_options (option_parser_t *parser)
   {
     {"text",           0, 0, G_OPTION_ARG_STRING,      &this->text,            
        "Set input text",                       "string"},
     {"text-file",      0, 0, G_OPTION_ARG_STRING,      &this->text_file,       
        "Set input text file-name\n\n    If no text is provided, standard input 
is used for input.",            "filename"},
+    {"text-before",    0, 0, G_OPTION_ARG_STRING,      &this->text_before,     
        "Set text context before each line",    "string"},
+    {"text-after",     0, 0, G_OPTION_ARG_STRING,      &this->text_after,      
        "Set text context after each line",     "string"},
     {NULL}
   };
   parser->add_group (entries,
diff --git a/util/options.hh b/util/options.hh
index 5d25d9e..0f6fce2 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -167,10 +167,18 @@ struct shape_options_t : option_group_t
     hb_buffer_set_language (buffer, hb_language_from_string (language, -1));
   }
 
-  void populate_buffer (hb_buffer_t *buffer, const char *text, int text_len)
+  void populate_buffer (hb_buffer_t *buffer, const char *text, int text_len,
+                       const char *text_before, const char *text_after)
   {
-    hb_buffer_reset (buffer);
+    hb_buffer_clear (buffer);
+    if (text_before) {
+      unsigned int len = strlen (text_before);
+      hb_buffer_add_utf8 (buffer, text_before, len, len, 0);
+    }
     hb_buffer_add_utf8 (buffer, text, text_len, 0, text_len);
+    if (text_after) {
+      hb_buffer_add_utf8 (buffer, text_after, -1, 0, 0);
+    }
 
     if (!utf8_clusters) {
       /* Reset cluster values to refer to Unicode character index
@@ -245,6 +253,9 @@ struct font_options_t : option_group_t
 struct text_options_t : option_group_t
 {
   text_options_t (option_parser_t *parser) {
+    text_before = NULL;
+    text_after = NULL;
+
     text = NULL;
     text_file = NULL;
 
@@ -273,6 +284,9 @@ struct text_options_t : option_group_t
 
   const char *get_line (unsigned int *len);
 
+  const char *text_before;
+  const char *text_after;
+
   const char *text;
   const char *text_file;
 
diff --git a/util/shape-consumer.hh b/util/shape-consumer.hh
index 220daa4..bf1a22d 100644
--- a/util/shape-consumer.hh
+++ b/util/shape-consumer.hh
@@ -45,11 +45,13 @@ struct shape_consumer_t
   }
   void consume_line (hb_buffer_t  *buffer,
                     const char   *text,
-                    unsigned int  text_len)
+                    unsigned int  text_len,
+                    const char   *text_before,
+                    const char   *text_after)
   {
     output.new_line ();
 
-    shaper.populate_buffer (buffer, text, text_len);
+    shaper.populate_buffer (buffer, text, text_len, text_before, text_after);
     output.consume_text (buffer, text, text_len, shaper.utf8_clusters);
 
     if (!shaper.shape (font, buffer)) {
commit e13f8d280bafc6a6b6e31e2eee587660b8333c56
Author: Behdad Esfahbod <[email protected]>
Date:   Tue Nov 13 15:12:06 2012 -0800

    Fix UTF-8 backward iteration
    
    Ouch!

diff --git a/src/hb-utf-private.hh b/src/hb-utf-private.hh
index 8cde827..ae36ef8 100644
--- a/src/hb-utf-private.hh
+++ b/src/hb-utf-private.hh
@@ -77,8 +77,8 @@ hb_utf_prev (const uint8_t *text,
             const uint8_t *start,
             hb_codepoint_t *unicode)
 {
-  const uint8_t *end = text;
-  while (start < text && (*--text & 0xc0) == 0x80 && end - text < 4)
+  const uint8_t *end = text--;
+  while (start < text && (*text & 0xc0) == 0x80 && end - text < 4)
     text--;
 
   hb_codepoint_t c = *text, mask;
commit 5669a6cf418f3a8b9281c36e9d662d843be80433
Author: Behdad Esfahbod <[email protected]>
Date:   Tue Nov 13 15:11:51 2012 -0800

    [Arabic] Fix post-context handling
    
    Ouch!

diff --git a/src/hb-ot-shape-complex-arabic.cc 
b/src/hb-ot-shape-complex-arabic.cc
index 59c9716..591c743 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -286,7 +286,7 @@ arabic_joining (hb_buffer_t *buffer)
   if (!(buffer->flags & HB_BUFFER_FLAG_EOT))
     for (unsigned int i = 0; i < buffer->context_len[1]; i++)
     {
-      unsigned int this_type = get_joining_type (buffer->context[1][i], 
buffer->unicode->general_category (buffer->context[0][i]));
+      unsigned int this_type = get_joining_type (buffer->context[1][i], 
buffer->unicode->general_category (buffer->context[1][i]));
 
       if (unlikely (this_type == JOINING_TYPE_T))
        continue;
_______________________________________________
HarfBuzz mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/harfbuzz

Reply via email to