[HarfBuzz] harfbuzz-ng: Branch 'master' - 8 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Sat Apr 7 12:10:53 PDT 2012


 src/Makefile.am                                                       |    1 
 src/hb-ot-layout-common-private.hh                                    |    1 
 src/hb-ot-shape-complex-arabic.cc                                     |    6 
 src/hb-ot-shape-complex-indic.cc                                      |    6 
 src/hb-ot-shape-complex-misc.cc                                       |   24 +
 src/hb-ot-shape-complex-private.hh                                    |   28 +-
 src/hb-ot-shape-normalize-private.hh                                  |   46 +++
 src/hb-ot-shape-normalize.cc                                          |  125 ++++------
 src/hb-ot-shape-private.hh                                            |   68 -----
 src/hb-ot-shape.cc                                                    |    4 
 src/hb-unicode-private.hh                                             |   11 
 src/hb-unicode.cc                                                     |   55 ++++
 test/shaping/texts/in-tree/shaper-default/MANIFEST                    |    1 
 test/shaping/texts/in-tree/shaper-default/script-hangul/MANIFEST      |    1 
 test/shaping/texts/in-tree/shaper-default/script-hangul/misc/MANIFEST |    1 
 test/shaping/texts/in-tree/shaper-default/script-hangul/misc/misc.txt |    2 
 16 files changed, 226 insertions(+), 154 deletions(-)

New commits:
commit c9a841f4452921c5361b8f5697bbff7736ce60cd
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Apr 7 15:06:55 2012 -0400

    Add simple Hangul shaper that recomposes Jamo when feasible
    
    Previously, we were NOT actually recomposing Hangul Jamo.  We do now.
    The two lines in:
    
    test/shaping/texts/in-tree/shaper-default/script-hangul/misc/misc.txt
    
    Now render the same with the UnDotum.ttf font.  Previously the second
    linle was rendering boxes.
    
    We can also start applying OpenType Jamo features later.  At this time,
    I have no idea how the 'ljmo', 'vjmo', 'tjmo' features are supposed to
    work.  Maybe someone can explain them to me?

diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc
index 98831fb..20e365b 100644
--- a/src/hb-ot-shape-complex-misc.cc
+++ b/src/hb-ot-shape-complex-misc.cc
@@ -53,3 +53,19 @@ _hb_ot_shape_complex_setup_masks_default (hb_ot_map_t *map, hb_buffer_t *buffer)
 }
 
 
+
+void
+_hb_ot_shape_complex_collect_features_hangul (hb_ot_map_builder_t *map, const hb_segment_properties_t  *props)
+{
+}
+
+hb_ot_shape_normalization_mode_t
+_hb_ot_shape_complex_normalization_preference_hangul (void)
+{
+  return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL;
+}
+
+void
+_hb_ot_shape_complex_setup_masks_hangul (hb_ot_map_t *map, hb_buffer_t *buffer)
+{
+}
diff --git a/src/hb-ot-shape-complex-private.hh b/src/hb-ot-shape-complex-private.hh
index ae01a3a..7c2c7a9 100644
--- a/src/hb-ot-shape-complex-private.hh
+++ b/src/hb-ot-shape-complex-private.hh
@@ -50,6 +50,7 @@
 #define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \
   HB_COMPLEX_SHAPER_IMPLEMENT (default) /* should be first */ \
   HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \
+  HB_COMPLEX_SHAPER_IMPLEMENT (hangul) \
   HB_COMPLEX_SHAPER_IMPLEMENT (indic) \
   /* ^--- Add new shapers here */
 
@@ -69,6 +70,7 @@ hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
     default:
       return hb_ot_complex_shaper_default;
 
+
     /* Unicode-1.1 additions */
     case HB_SCRIPT_ARABIC:
     case HB_SCRIPT_MONGOLIAN:
@@ -82,6 +84,17 @@ hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
 
       return hb_ot_complex_shaper_arabic;
 
+
+    /* Unicode-1.1 additions */
+    case HB_SCRIPT_HANGUL:
+
+      return hb_ot_complex_shaper_hangul;
+
+
+
+    /* ^--- Add new shapers here */
+
+
 #if 0
     /* Note:
      *
@@ -191,8 +204,6 @@ hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
     case HB_SCRIPT_TAKRI:
 
       return hb_ot_complex_shaper_indic;
-
-    /* ^--- Add new shapers here */
   }
 }
 
commit 968318455304804dc53045e8ba0cd4d76800c02d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Apr 7 14:57:21 2012 -0400

    Implement normalization mode HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL
    
    In this mode we try composing CCC=0 with CCC=0 characters.  Useful for
    Hangul.

diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index 02a90bf..f7b3547 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -198,7 +198,7 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
   buffer->swap_buffers ();
 
 
-  if (!has_multichar_clusters)
+  if (mode != HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL && !has_multichar_clusters)
     return; /* Done! */
 
 
@@ -243,19 +243,21 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
   buffer->next_glyph ();
   while (buffer->idx < count)
   {
-    if (buffer->info[buffer->idx].combining_class() == 0) {
-      starter = buffer->out_len;
-      buffer->next_glyph ();
-      continue;
-    }
-
     hb_codepoint_t composed, glyph;
-    if ((starter == buffer->out_len - 1 ||
+    if (/* If mode is NOT COMPOSED_FULL (ie. it's COMPOSED_DIACRITICS), we don't try to
+	 * compose a CCC=0 character with it's preceding starter. */
+	(mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL ||
+	 buffer->info[buffer->idx].combining_class() != 0) &&
+	/* If there's anything between the starter and this char, they should have CCC
+	 * smaller than this character's. */
+	(starter == buffer->out_len - 1 ||
 	 buffer->out_info[buffer->out_len - 1].combining_class() < buffer->info[buffer->idx].combining_class()) &&
+	/* And compose. */
 	hb_unicode_compose (buffer->unicode,
 			    buffer->out_info[starter].codepoint,
 			    buffer->info[buffer->idx].codepoint,
 			    &composed) &&
+	/* And the font has glyph for the composite. */
 	hb_font_get_glyph (font, composed, 0, &glyph))
     {
       /* Composes. Modify starter and carry on. */
@@ -268,6 +270,9 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
 
     /* Blocked, or doesn't compose. */
     buffer->next_glyph ();
+
+    if (buffer->out_info[buffer->out_len - 1].combining_class() == 0)
+      starter = buffer->out_len - 1;
   }
   buffer->swap_buffers ();
 
commit bec2ac4fde1ba0dd6dba02adbb836ce569a5cf6f
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Apr 7 14:51:17 2012 -0400

    Bring normalization algorithm closer to the spec
    
    No logical difference so far.

diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index f24fb32..02a90bf 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -250,7 +250,8 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
     }
 
     hb_codepoint_t composed, glyph;
-    if ((buffer->out_info[buffer->out_len - 1].combining_class() < buffer->info[buffer->idx].combining_class()) &&
+    if ((starter == buffer->out_len - 1 ||
+	 buffer->out_info[buffer->out_len - 1].combining_class() < buffer->info[buffer->idx].combining_class()) &&
 	hb_unicode_compose (buffer->unicode,
 			    buffer->out_info[starter].codepoint,
 			    buffer->info[buffer->idx].codepoint,
commit e02d9257863b49e33ab5942971266349d3c548f6
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Apr 7 14:49:13 2012 -0400

    Flip logic around

diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index 15de312..f24fb32 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -198,17 +198,6 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
   buffer->swap_buffers ();
 
 
-  /* Technically speaking, two characters with ccc=0 may combine.  But all
-   * those cases are in languages that the indic module handles (which expects
-   * decomposed), or in Hangul jamo, which again, we want decomposed anyway.
-   * So we don't bother combining across cluster boundaries.  This is a huge
-   * performance saver if the compose() callback is slow.
-   *
-   * TODO: Am I right about Hangul?  If I am, we should add a Hangul module
-   * that requests decomposed.  If for Hangul we end up wanting composed, we
-   * can do that in the Hangul module.
-   */
-
   if (!has_multichar_clusters)
     return; /* Done! */
 
@@ -261,24 +250,23 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
     }
 
     hb_codepoint_t composed, glyph;
-    if ((buffer->out_info[buffer->out_len - 1].combining_class() >=
-	 buffer->info[buffer->idx].combining_class()) ||
-	!hb_unicode_compose (buffer->unicode,
-			     buffer->out_info[starter].codepoint,
-			     buffer->info[buffer->idx].codepoint,
-			     &composed) ||
-	!hb_font_get_glyph (font, composed, 0, &glyph))
+    if ((buffer->out_info[buffer->out_len - 1].combining_class() < buffer->info[buffer->idx].combining_class()) &&
+	hb_unicode_compose (buffer->unicode,
+			    buffer->out_info[starter].codepoint,
+			    buffer->info[buffer->idx].codepoint,
+			    &composed) &&
+	hb_font_get_glyph (font, composed, 0, &glyph))
     {
-      /* Blocked, or doesn't compose. */
-      buffer->next_glyph ();
+      /* Composes. Modify starter and carry on. */
+      buffer->out_info[starter].codepoint = composed;
+      hb_glyph_info_set_unicode_props (&buffer->out_info[starter], buffer->unicode);
+
+      buffer->skip_glyph ();
       continue;
     }
 
-    /* Composes. Modify starter and carry on. */
-    buffer->out_info[starter].codepoint = composed;
-    hb_glyph_info_set_unicode_props (&buffer->out_info[starter], buffer->unicode);
-
-    buffer->skip_glyph ();
+    /* Blocked, or doesn't compose. */
+    buffer->next_glyph ();
   }
   buffer->swap_buffers ();
 
commit aaa25d5f458127f53f4b5ecdeb986ae91fabbad3
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 5 17:27:23 2012 -0400

    Add Hangul test case
    
    Composed, and decomposed, of the same text.

diff --git a/test/shaping/texts/in-tree/shaper-default/MANIFEST b/test/shaping/texts/in-tree/shaper-default/MANIFEST
index 5139532..623eae4 100644
--- a/test/shaping/texts/in-tree/shaper-default/MANIFEST
+++ b/test/shaping/texts/in-tree/shaper-default/MANIFEST
@@ -1,2 +1,3 @@
+script-hangul
 script-hebrew
 script-linear-b
diff --git a/test/shaping/texts/in-tree/shaper-default/script-hangul/MANIFEST b/test/shaping/texts/in-tree/shaper-default/script-hangul/MANIFEST
new file mode 100644
index 0000000..b8752e7
--- /dev/null
+++ b/test/shaping/texts/in-tree/shaper-default/script-hangul/MANIFEST
@@ -0,0 +1 @@
+misc
diff --git a/test/shaping/texts/in-tree/shaper-default/script-hangul/misc/MANIFEST b/test/shaping/texts/in-tree/shaper-default/script-hangul/misc/MANIFEST
new file mode 100644
index 0000000..29cfb2f
--- /dev/null
+++ b/test/shaping/texts/in-tree/shaper-default/script-hangul/misc/MANIFEST
@@ -0,0 +1 @@
+misc.txt
diff --git a/test/shaping/texts/in-tree/shaper-default/script-hangul/misc/misc.txt b/test/shaping/texts/in-tree/shaper-default/script-hangul/misc/misc.txt
new file mode 100644
index 0000000..9c374b9
--- /dev/null
+++ b/test/shaping/texts/in-tree/shaper-default/script-hangul/misc/misc.txt
@@ -0,0 +1,2 @@
+휴가 가-- (오--)
+휴가 가-- (오--)
commit 11138ccff71f442da1fcf64faa0e1d22e083e775
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 5 17:25:19 2012 -0400

    Add normalize mode
    
    In preparation for Hangul shaper.

diff --git a/src/Makefile.am b/src/Makefile.am
index c70e198..d64efdf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -70,6 +70,7 @@ HBSOURCES += \
 	hb-ot-shape-complex-indic-table.hh \
 	hb-ot-shape-complex-misc.cc \
 	hb-ot-shape-complex-private.hh \
+	hb-ot-shape-normalize-private.hh \
 	hb-ot-shape-normalize.cc \
 	hb-ot-shape-private.hh \
 	$(NULL)
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 5d19e08..d478e29 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -30,7 +30,6 @@
 #define HB_OT_LAYOUT_COMMON_PRIVATE_HH
 
 #include "hb-ot-layout-private.hh"
-
 #include "hb-open-type-private.hh"
 
 
diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index 2b863ef..89d6b53 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -183,10 +183,10 @@ _hb_ot_shape_complex_collect_features_arabic (hb_ot_map_builder_t *map, const hb
   map->add_bool_feature (HB_TAG('c','s','w','h'));
 }
 
-bool
-_hb_ot_shape_complex_prefer_decomposed_arabic (void)
+hb_ot_shape_normalization_mode_t
+_hb_ot_shape_complex_normalization_preference_arabic (void)
 {
-  return FALSE;
+  return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS;
 }
 
 void
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 9f50ef2..9dcba81 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -369,11 +369,11 @@ _hb_ot_shape_complex_collect_features_indic (hb_ot_map_builder_t *map, const hb_
 }
 
 
-bool
-_hb_ot_shape_complex_prefer_decomposed_indic (void)
+hb_ot_shape_normalization_mode_t
+_hb_ot_shape_complex_normalization_preference_indic (void)
 {
   /* We want split matras decomposed by the common shaping logic. */
-  return TRUE;
+  return HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED;
 }
 
 
diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc
index 230704f..98831fb 100644
--- a/src/hb-ot-shape-complex-misc.cc
+++ b/src/hb-ot-shape-complex-misc.cc
@@ -27,7 +27,7 @@
 #include "hb-ot-shape-complex-private.hh"
 
 
-/* TODO Add kana, hangul, and other small sahpers here */
+/* TODO Add kana, hangul, and other small shapers here */
 
 /* When adding trivial shapers, eg. kana, hangul, etc, we can either
  * add a full shaper enum value for them, or switch on the script in
@@ -41,10 +41,10 @@ _hb_ot_shape_complex_collect_features_default (hb_ot_map_builder_t *map, const h
 {
 }
 
-bool
-_hb_ot_shape_complex_prefer_decomposed_default (void)
+hb_ot_shape_normalization_mode_t
+_hb_ot_shape_complex_normalization_preference_default (void)
 {
-  return FALSE;
+  return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS;
 }
 
 void
diff --git a/src/hb-ot-shape-complex-private.hh b/src/hb-ot-shape-complex-private.hh
index 32ac854..ae01a3a 100644
--- a/src/hb-ot-shape-complex-private.hh
+++ b/src/hb-ot-shape-complex-private.hh
@@ -30,6 +30,7 @@
 #include "hb-private.hh"
 
 #include "hb-ot-map-private.hh"
+#include "hb-ot-shape-normalize-private.hh"
 
 
 
@@ -227,26 +228,26 @@ hb_ot_shape_complex_collect_features (hb_ot_complex_shaper_t shaper,
 
 
 /*
- * prefer_decomposed()
+ * normalization_preference()
  *
  * Called during shape_execute().
  *
  * Shapers should return TRUE if it prefers decomposed (NFD) input rather than precomposed (NFC).
  */
 
-typedef bool hb_ot_shape_complex_prefer_decomposed_func_t (void);
+typedef hb_ot_shape_normalization_mode_t hb_ot_shape_complex_normalization_preference_func_t (void);
 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
-  HB_INTERNAL hb_ot_shape_complex_prefer_decomposed_func_t _hb_ot_shape_complex_prefer_decomposed_##name;
+  HB_INTERNAL hb_ot_shape_complex_normalization_preference_func_t _hb_ot_shape_complex_normalization_preference_##name;
   HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
 #undef HB_COMPLEX_SHAPER_IMPLEMENT
 
-static inline bool
-hb_ot_shape_complex_prefer_decomposed (hb_ot_complex_shaper_t shaper)
+static inline hb_ot_shape_normalization_mode_t
+hb_ot_shape_complex_normalization_preference (hb_ot_complex_shaper_t shaper)
 {
   switch (shaper) {
     default:
 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
-    case hb_ot_complex_shaper_##name:	return _hb_ot_shape_complex_prefer_decomposed_##name ();
+    case hb_ot_complex_shaper_##name:	return _hb_ot_shape_complex_normalization_preference_##name ();
     HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
 #undef HB_COMPLEX_SHAPER_IMPLEMENT
   }
diff --git a/src/hb-ot-shape-normalize-private.hh b/src/hb-ot-shape-normalize-private.hh
new file mode 100644
index 0000000..bb81f00
--- /dev/null
+++ b/src/hb-ot-shape-normalize-private.hh
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2012  Google, Inc.
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#ifndef HB_OT_SHAPE_NORMALIZE_PRIVATE_HH
+#define HB_OT_SHAPE_NORMALIZE_PRIVATE_HH
+
+#include "hb-private.hh"
+
+#include "hb-font.h"
+#include "hb-buffer.h"
+
+
+enum hb_ot_shape_normalization_mode_t {
+  HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED,
+  HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS, /* never composes base-to-base */
+  HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL /* including base-to-base composition */
+};
+
+HB_INTERNAL void _hb_ot_shape_normalize (hb_font_t *font,
+					 hb_buffer_t *buffer,
+					 hb_ot_shape_normalization_mode_t mode);
+
+#endif /* HB_OT_SHAPE_NORMALIZE_PRIVATE_HH */
diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index a1ad6d7..15de312 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2011  Google, Inc.
+ * Copyright © 2011,2012  Google, Inc.
  *
  *  This is part of HarfBuzz, a text shaping library.
  *
@@ -24,8 +24,8 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb-ot-shape-normalize-private.hh"
 #include "hb-ot-shape-private.hh"
-#include "hb-ot-shape-complex-private.hh"
 
 
 /*
@@ -69,45 +69,43 @@
  */
 
 static void
-output_glyph (hb_ot_shape_context_t *c,
+output_glyph (hb_font_t *font, hb_buffer_t *buffer,
 	      hb_codepoint_t glyph)
 {
-  hb_buffer_t *buffer = c->buffer;
-
   buffer->output_glyph (glyph);
   hb_glyph_info_set_unicode_props (&buffer->out_info[buffer->out_len - 1], buffer->unicode);
 }
 
 static bool
-decompose (hb_ot_shape_context_t *c,
+decompose (hb_font_t *font, hb_buffer_t *buffer,
 	   bool shortest,
 	   hb_codepoint_t ab)
 {
   hb_codepoint_t a, b, glyph;
 
-  if (!hb_unicode_decompose (c->buffer->unicode, ab, &a, &b) ||
-      (b && !hb_font_get_glyph (c->font, b, 0, &glyph)))
+  if (!hb_unicode_decompose (buffer->unicode, ab, &a, &b) ||
+      (b && !hb_font_get_glyph (font, b, 0, &glyph)))
     return FALSE;
 
-  bool has_a = hb_font_get_glyph (c->font, a, 0, &glyph);
+  bool has_a = hb_font_get_glyph (font, a, 0, &glyph);
   if (shortest && has_a) {
     /* Output a and b */
-    output_glyph (c, a);
+    output_glyph (font, buffer, a);
     if (b)
-      output_glyph (c, b);
+      output_glyph (font, buffer, b);
     return TRUE;
   }
 
-  if (decompose (c, shortest, a)) {
+  if (decompose (font, buffer, shortest, a)) {
     if (b)
-      output_glyph (c, b);
+      output_glyph (font, buffer, b);
     return TRUE;
   }
 
   if (has_a) {
-    output_glyph (c, a);
+    output_glyph (font, buffer, a);
     if (b)
-      output_glyph (c, b);
+      output_glyph (font, buffer, b);
     return TRUE;
   }
 
@@ -115,44 +113,44 @@ decompose (hb_ot_shape_context_t *c,
 }
 
 static void
-decompose_current_glyph (hb_ot_shape_context_t *c,
+decompose_current_glyph (hb_font_t *font, hb_buffer_t *buffer,
 			 bool shortest)
 {
-  if (decompose (c, shortest, c->buffer->info[c->buffer->idx].codepoint))
-    c->buffer->skip_glyph ();
+  if (decompose (font, buffer, shortest, buffer->info[buffer->idx].codepoint))
+    buffer->skip_glyph ();
   else
-    c->buffer->next_glyph ();
+    buffer->next_glyph ();
 }
 
 static void
-decompose_single_char_cluster (hb_ot_shape_context_t *c,
+decompose_single_char_cluster (hb_font_t *font, hb_buffer_t *buffer,
 			       bool will_recompose)
 {
   hb_codepoint_t glyph;
 
   /* If recomposing and font supports this, we're good to go */
-  if (will_recompose && hb_font_get_glyph (c->font, c->buffer->info[c->buffer->idx].codepoint, 0, &glyph)) {
-    c->buffer->next_glyph ();
+  if (will_recompose && hb_font_get_glyph (font, buffer->info[buffer->idx].codepoint, 0, &glyph)) {
+    buffer->next_glyph ();
     return;
   }
 
-  decompose_current_glyph (c, will_recompose);
+  decompose_current_glyph (font, buffer, will_recompose);
 }
 
 static void
-decompose_multi_char_cluster (hb_ot_shape_context_t *c,
+decompose_multi_char_cluster (hb_font_t *font, hb_buffer_t *buffer,
 			      unsigned int end)
 {
   /* TODO Currently if there's a variation-selector we give-up, it's just too hard. */
-  for (unsigned int i = c->buffer->idx; i < end; i++)
-    if (unlikely (_hb_unicode_is_variation_selector (c->buffer->info[i].codepoint))) {
-      while (c->buffer->idx < end)
-	c->buffer->next_glyph ();
+  for (unsigned int i = buffer->idx; i < end; i++)
+    if (unlikely (_hb_unicode_is_variation_selector (buffer->info[i].codepoint))) {
+      while (buffer->idx < end)
+	buffer->next_glyph ();
       return;
     }
 
-  while (c->buffer->idx < end)
-    decompose_current_glyph (c, FALSE);
+  while (buffer->idx < end)
+    decompose_current_glyph (font, buffer, FALSE);
 }
 
 static int
@@ -165,10 +163,10 @@ compare_combining_class (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb)
 }
 
 void
-_hb_ot_shape_normalize (hb_ot_shape_context_t *c)
+_hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
+			hb_ot_shape_normalization_mode_t mode)
 {
-  hb_buffer_t *buffer = c->buffer;
-  bool recompose = !hb_ot_shape_complex_prefer_decomposed (c->plan->shaper);
+  bool recompose = mode != HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED;
   bool has_multichar_clusters = FALSE;
   unsigned int count;
 
@@ -191,9 +189,9 @@ _hb_ot_shape_normalize (hb_ot_shape_context_t *c)
         break;
 
     if (buffer->idx + 1 == end)
-      decompose_single_char_cluster (c, recompose);
+      decompose_single_char_cluster (font, buffer, recompose);
     else {
-      decompose_multi_char_cluster (c, end);
+      decompose_multi_char_cluster (font, buffer, end);
       has_multichar_clusters = TRUE;
     }
   }
@@ -265,11 +263,11 @@ _hb_ot_shape_normalize (hb_ot_shape_context_t *c)
     hb_codepoint_t composed, glyph;
     if ((buffer->out_info[buffer->out_len - 1].combining_class() >=
 	 buffer->info[buffer->idx].combining_class()) ||
-	!hb_unicode_compose (c->buffer->unicode,
+	!hb_unicode_compose (buffer->unicode,
 			     buffer->out_info[starter].codepoint,
 			     buffer->info[buffer->idx].codepoint,
 			     &composed) ||
-	!hb_font_get_glyph (c->font, composed, 0, &glyph))
+	!hb_font_get_glyph (font, composed, 0, &glyph))
     {
       /* Blocked, or doesn't compose. */
       buffer->next_glyph ();
@@ -285,4 +283,3 @@ _hb_ot_shape_normalize (hb_ot_shape_context_t *c)
   buffer->swap_buffers ();
 
 }
-
diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh
index 7347377..0e33dae 100644
--- a/src/hb-ot-shape-private.hh
+++ b/src/hb-ot-shape-private.hh
@@ -33,11 +33,9 @@
 
 #include "hb-ot-map-private.hh"
 #include "hb-ot-shape-complex-private.hh"
+#include "hb-ot-shape-normalize-private.hh"
 
 
-
-enum hb_ot_complex_shaper_t;
-
 struct hb_ot_shape_plan_t
 {
   friend struct hb_ot_shape_planner_t;
@@ -99,7 +97,6 @@ hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unic
 
 HB_INTERNAL void _hb_set_unicode_props (hb_buffer_t *buffer);
 
-HB_INTERNAL void _hb_ot_shape_normalize (hb_ot_shape_context_t *c);
-
+#include "hb-ot-shape-complex-private.hh"
 
 #endif /* HB_OT_SHAPE_PRIVATE_HH */
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index d61eb75..d0d1850 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -362,7 +362,7 @@ hb_ot_shape_execute_internal (hb_ot_shape_context_t *c)
 
   hb_ensure_native_direction (c->buffer);
 
-  _hb_ot_shape_normalize (c);
+  _hb_ot_shape_normalize (c->font, c->buffer, hb_ot_shape_complex_normalization_preference (c->plan->shaper));
 
   hb_ot_shape_setup_masks (c);
 
commit 6769f21d579a354e32577ec57348e97d2cb1b438
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 5 16:46:46 2012 -0400

    More moving code around

diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index a754590..a1ad6d7 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -145,7 +145,7 @@ decompose_multi_char_cluster (hb_ot_shape_context_t *c,
 {
   /* TODO Currently if there's a variation-selector we give-up, it's just too hard. */
   for (unsigned int i = c->buffer->idx; i < end; i++)
-    if (unlikely (is_variation_selector (c->buffer->info[i].codepoint))) {
+    if (unlikely (_hb_unicode_is_variation_selector (c->buffer->info[i].codepoint))) {
       while (c->buffer->idx < end)
 	c->buffer->next_glyph ();
       return;
diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh
index 78564f8..7347377 100644
--- a/src/hb-ot-shape-private.hh
+++ b/src/hb-ot-shape-private.hh
@@ -90,14 +90,6 @@ struct hb_ot_shape_context_t
 };
 
 
-static inline hb_bool_t
-is_variation_selector (hb_codepoint_t unicode)
-{
-  return unlikely ((unicode >=  0x180B && unicode <=  0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
-		   (unicode >=  0xFE00 && unicode <=  0xFE0F) || /* VARIATION SELECTOR-1..16 */
-		   (unicode >= 0xE0100 && unicode <= 0xE01EF));  /* VARIATION SELECTOR-17..256 */
-}
-
 static inline void
 hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode)
 {
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 4275afc..d61eb75 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -205,7 +205,7 @@ hb_map_glyphs (hb_font_t    *font,
 
   unsigned int count = buffer->len - 1;
   for (buffer->idx = 0; buffer->idx < count;) {
-    if (unlikely (is_variation_selector (buffer->info[buffer->idx + 1].codepoint))) {
+    if (unlikely (_hb_unicode_is_variation_selector (buffer->info[buffer->idx + 1].codepoint))) {
       hb_font_get_glyph (font, buffer->info[buffer->idx].codepoint, buffer->info[buffer->idx + 1].codepoint, &glyph);
       buffer->replace_glyph (glyph);
       buffer->skip_glyph ();
diff --git a/src/hb-unicode-private.hh b/src/hb-unicode-private.hh
index 7fdf646..ad85be7 100644
--- a/src/hb-unicode-private.hh
+++ b/src/hb-unicode-private.hh
@@ -106,5 +106,13 @@ HB_INTERNAL unsigned int
 _hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs,
 				      hb_codepoint_t      unicode);
 
+static inline hb_bool_t
+_hb_unicode_is_variation_selector (hb_codepoint_t unicode)
+{
+  return unlikely ((unicode >=  0x180B && unicode <=  0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
+		   (unicode >=  0xFE00 && unicode <=  0xFE0F) || /* VARIATION SELECTOR-1..16 */
+		   (unicode >= 0xE0100 && unicode <= 0xE01EF));  /* VARIATION SELECTOR-17..256 */
+}
+
 
 #endif /* HB_UNICODE_PRIVATE_HH */
commit 2db2a566826ed4763ce69629194ec656bd48b0bd
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 5 16:40:37 2012 -0400

    Move code around

diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh
index 87e8ddb..78564f8 100644
--- a/src/hb-ot-shape-private.hh
+++ b/src/hb-ot-shape-private.hh
@@ -98,59 +98,6 @@ is_variation_selector (hb_codepoint_t unicode)
 		   (unicode >= 0xE0100 && unicode <= 0xE01EF));  /* VARIATION SELECTOR-17..256 */
 }
 
-static inline unsigned int
-_hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs,
-				      hb_codepoint_t      unicode)
-{
-  int c = hb_unicode_combining_class (ufuncs, unicode);
-
-  if (unlikely (hb_in_range<int> (c, 27, 33)))
-  {
-    /* Modify the combining-class to suit Arabic better.  See:
-     * http://unicode.org/faq/normalization.html#8
-     * http://unicode.org/faq/normalization.html#9
-     */
-    c = c == 33 ? 27 : c + 1;
-  }
-  else if (unlikely (hb_in_range<int> (c, 10, 25)))
-  {
-    /* The equivalent fix for Hebrew is more complex.
-     *
-     * We permute the "fixed-position" classes 10-25 into the order
-     * described in the SBL Hebrew manual:
-     *
-     * http://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf
-     *
-     * (as recommended by:
-     *  http://forum.fontlab.com/archive-old-microsoft-volt-group/vista-and-diacritic-ordering-t6751.0.html)
-     *
-     * More details here:
-     * https://bugzilla.mozilla.org/show_bug.cgi?id=662055
-     */
-    static const int permuted_hebrew_classes[25 - 10 + 1] = {
-      /* 10 sheva */        22,
-      /* 11 hataf segol */  15,
-      /* 12 hataf patah */  16,
-      /* 13 hataf qamats */ 17,
-      /* 14 hiriq */        23,
-      /* 15 tsere */        18,
-      /* 16 segol */        19,
-      /* 17 patah */        20,
-      /* 18 qamats */       21,
-      /* 19 holam */        14,
-      /* 20 qubuts */       24,
-      /* 21 dagesh */       12,
-      /* 22 meteg */        25,
-      /* 23 rafe */         13,
-      /* 24 shin dot */     10,
-      /* 25 sin dot */      11,
-    };
-    c = permuted_hebrew_classes[c - 10];
-  }
-
-  return c;
-}
-
 static inline void
 hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode)
 {
diff --git a/src/hb-unicode-private.hh b/src/hb-unicode-private.hh
index 2ad8a49..7fdf646 100644
--- a/src/hb-unicode-private.hh
+++ b/src/hb-unicode-private.hh
@@ -102,6 +102,9 @@ extern HB_INTERNAL hb_unicode_funcs_t _hb_unicode_funcs_nil;
 #endif
 
 
+HB_INTERNAL unsigned int
+_hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs,
+				      hb_codepoint_t      unicode);
 
 
 #endif /* HB_UNICODE_PRIVATE_HH */
diff --git a/src/hb-unicode.cc b/src/hb-unicode.cc
index 4b285c5..a660ccc 100644
--- a/src/hb-unicode.cc
+++ b/src/hb-unicode.cc
@@ -271,3 +271,58 @@ hb_unicode_decompose (hb_unicode_funcs_t *ufuncs,
   return ufuncs->func.decompose (ufuncs, ab, a, b, ufuncs->user_data.decompose);
 }
 
+
+
+unsigned int
+_hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs,
+				      hb_codepoint_t      unicode)
+{
+  int c = hb_unicode_combining_class (ufuncs, unicode);
+
+  if (unlikely (hb_in_range<int> (c, 27, 33)))
+  {
+    /* Modify the combining-class to suit Arabic better.  See:
+     * http://unicode.org/faq/normalization.html#8
+     * http://unicode.org/faq/normalization.html#9
+     */
+    c = c == 33 ? 27 : c + 1;
+  }
+  else if (unlikely (hb_in_range<int> (c, 10, 25)))
+  {
+    /* The equivalent fix for Hebrew is more complex.
+     *
+     * We permute the "fixed-position" classes 10-25 into the order
+     * described in the SBL Hebrew manual:
+     *
+     * http://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf
+     *
+     * (as recommended by:
+     *  http://forum.fontlab.com/archive-old-microsoft-volt-group/vista-and-diacritic-ordering-t6751.0.html)
+     *
+     * More details here:
+     * https://bugzilla.mozilla.org/show_bug.cgi?id=662055
+     */
+    static const int permuted_hebrew_classes[25 - 10 + 1] = {
+      /* 10 sheva */        22,
+      /* 11 hataf segol */  15,
+      /* 12 hataf patah */  16,
+      /* 13 hataf qamats */ 17,
+      /* 14 hiriq */        23,
+      /* 15 tsere */        18,
+      /* 16 segol */        19,
+      /* 17 patah */        20,
+      /* 18 qamats */       21,
+      /* 19 holam */        14,
+      /* 20 qubuts */       24,
+      /* 21 dagesh */       12,
+      /* 22 meteg */        25,
+      /* 23 rafe */         13,
+      /* 24 shin dot */     10,
+      /* 25 sin dot */      11,
+    };
+    c = permuted_hebrew_classes[c - 10];
+  }
+
+  return c;
+}
+



More information about the HarfBuzz mailing list