[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Jan 2 01:04:47 PST 2014


 src/hb-ot-shape-complex-hangul.cc    |    2 +-
 src/hb-ot-shape-normalize-private.hh |    1 +
 src/hb-ot-shape-normalize.cc         |   24 +++++++++++++-----------
 3 files changed, 15 insertions(+), 12 deletions(-)

New commits:
commit 8fc1f7fe74a25bf8549f5edd79c7da6b720eb064
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Jan 2 17:04:04 2014 +0800

    [ot/hangul] Don't decompose Hangul even when combining marks present
    
    As discussed on
    https://github.com/behdad/harfbuzz/pull/10#issuecomment-31442030

diff --git a/src/hb-ot-shape-complex-hangul.cc b/src/hb-ot-shape-complex-hangul.cc
index 7353848..7c137c6 100644
--- a/src/hb-ot-shape-complex-hangul.cc
+++ b/src/hb-ot-shape-complex-hangul.cc
@@ -218,7 +218,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hangul =
   NULL, /* data_create */
   NULL, /* data_destroy */
   preprocess_text_hangul,
-  HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT,
+  HB_OT_SHAPE_NORMALIZATION_MODE_NONE,
   NULL, /* decompose */
   NULL, /* compose */
   NULL, /* setup_masks */
diff --git a/src/hb-ot-shape-normalize-private.hh b/src/hb-ot-shape-normalize-private.hh
index fb8048c..c744e26 100644
--- a/src/hb-ot-shape-normalize-private.hh
+++ b/src/hb-ot-shape-normalize-private.hh
@@ -36,6 +36,7 @@
 struct hb_ot_shape_plan_t;
 
 enum hb_ot_shape_normalization_mode_t {
+  HB_OT_SHAPE_NORMALIZATION_MODE_NONE,
   HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED,
   HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS, /* never composes base-to-base */
   HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, /* always fully decomposes and then recompose back */
diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index 710536e..94fc4a9 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -213,8 +213,9 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor
 }
 
 static inline void
-handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end)
+handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool short_circuit)
 {
+  /* TODO Currently if there's a variation-selector we give-up, it's just too hard. */
   hb_buffer_t * const buffer = c->buffer;
   hb_font_t * const font = c->font;
   for (; buffer->idx < end - 1;) {
@@ -250,27 +251,26 @@ handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns
 }
 
 static inline void
-decompose_multi_char_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end)
+decompose_multi_char_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool short_circuit)
 {
   hb_buffer_t * const buffer = c->buffer;
-  /* TODO Currently if there's a variation-selector we give-up, it's just too hard. */
   for (unsigned int i = buffer->idx; i < end; i++)
     if (unlikely (buffer->unicode->is_variation_selector (buffer->info[i].codepoint))) {
-      handle_variation_selector_cluster (c, end);
+      handle_variation_selector_cluster (c, end, short_circuit);
       return;
     }
 
   while (buffer->idx < end)
-    decompose_current_character (c, false);
+    decompose_current_character (c, short_circuit);
 }
 
 static inline void
-decompose_cluster (const hb_ot_shape_normalize_context_t *c, bool short_circuit, unsigned int end)
+decompose_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool might_short_circuit, bool always_short_circuit)
 {
   if (likely (c->buffer->idx + 1 == end))
-    decompose_current_character (c, short_circuit);
+    decompose_current_character (c, might_short_circuit);
   else
-    decompose_multi_char_cluster (c, end);
+    decompose_multi_char_cluster (c, end, always_short_circuit);
 }
 
 
@@ -299,8 +299,10 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
     plan->shaper->compose   ? plan->shaper->compose   : compose_unicode
   };
 
-  bool short_circuit = mode != HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED &&
-		       mode != HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT;
+  bool always_short_circuit = mode == HB_OT_SHAPE_NORMALIZATION_MODE_NONE;
+  bool might_short_circuit = always_short_circuit ||
+			     (mode != HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED &&
+			      mode != HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT);
   unsigned int count;
 
   /* We do a fairly straightforward yet custom normalization process in three
@@ -321,7 +323,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
       if (buffer->cur().cluster != buffer->info[end].cluster)
         break;
 
-    decompose_cluster (&c, short_circuit, end);
+    decompose_cluster (&c, end, might_short_circuit, always_short_circuit);
   }
   buffer->swap_buffers ();
 


More information about the HarfBuzz mailing list