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

Behdad Esfahbod behdad at kemper.freedesktop.org
Sat Sep 1 17:06:53 PDT 2012


 src/hb-ot-shape-fallback-private.hh |    5 +
 src/hb-ot-shape-fallback.cc         |   98 +++++++++++++++++++++++++++---------
 src/hb-ot-shape-private.hh          |    6 ++
 src/hb-ot-shape.cc                  |    4 +
 4 files changed, 90 insertions(+), 23 deletions(-)

New commits:
commit 1d581ec384bc1780995e32e1c44103af57596eda
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Sep 1 20:06:26 2012 -0400

    [OT] Fallback-position ccc=0 Thai / Lao marks
    
    Not perfect, but so is fallback positioning in 2012...

diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc
index b88fa83..8f7eb47 100644
--- a/src/hb-ot-shape-fallback.cc
+++ b/src/hb-ot-shape-fallback.cc
@@ -28,14 +28,53 @@
 
 static unsigned int
 recategorize_combining_class (hb_codepoint_t u,
-			      unsigned int modified_combining_class)
+			      unsigned int klass)
 {
-  if (modified_combining_class >= 200)
-    return modified_combining_class;
+  if (klass >= 200)
+    return klass;
 
-  /* This should be kept in sync with modified combining class mapping
-   * from hb-unicode.cc. */
-  switch (modified_combining_class)
+  /* Thai / Lao need some per-character work. */
+  if ((u & ~0xFF) == 0x0E00)
+  {
+    if (unlikely (klass == 0))
+    {
+      switch (u)
+      {
+        case 0x0E31:
+        case 0x0E34:
+        case 0x0E35:
+        case 0x0E36:
+        case 0x0E37:
+        case 0x0E47:
+        case 0x0E4C:
+        case 0x0E4D:
+        case 0x0E4E:
+	  klass = HB_UNICODE_COMBINING_CLASS_ABOVE_RIGHT;
+	  break;
+
+        case 0x0EB1:
+        case 0x0EB4:
+        case 0x0EB5:
+        case 0x0EB6:
+        case 0x0EB7:
+        case 0x0EBB:
+        case 0x0ECC:
+        case 0x0ECD:
+	  klass = HB_UNICODE_COMBINING_CLASS_ABOVE;
+	  break;
+
+        case 0x0EBC:
+	  klass = HB_UNICODE_COMBINING_CLASS_BELOW;
+	  break;
+      }
+    } else {
+      /* Thai virama is below-right */
+      if (u == 0x0E3A)
+	klass = HB_UNICODE_COMBINING_CLASS_BELOW_RIGHT;
+    }
+  }
+
+  switch (klass)
   {
 
     /* Hebrew */
@@ -89,9 +128,6 @@ recategorize_combining_class (hb_codepoint_t u,
 
     /* Thai */
 
-    /* Note: to be useful we also need to position U+0E3A that has ccc=9 (virama).
-     * But viramas can be both above and below based on the codepoint / script. */
-
     case HB_MODIFIED_COMBINING_CLASS_CCC103: /* sara u / sara uu */
       return HB_UNICODE_COMBINING_CLASS_BELOW_RIGHT;
 
@@ -121,7 +157,7 @@ recategorize_combining_class (hb_codepoint_t u,
 
   }
 
-  return modified_combining_class;
+  return klass;
 }
 
 void
commit 3992b5ec4cb43d114d87ff7ee2b992bcf819c9cd
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Sep 1 19:20:41 2012 -0400

    Move code around

diff --git a/src/hb-ot-shape-fallback-private.hh b/src/hb-ot-shape-fallback-private.hh
index be96c4f..5e9cb06 100644
--- a/src/hb-ot-shape-fallback-private.hh
+++ b/src/hb-ot-shape-fallback-private.hh
@@ -36,4 +36,9 @@ HB_INTERNAL void _hb_ot_shape_fallback_position (const hb_ot_shape_plan_t *plan,
 						 hb_font_t *font,
 						 hb_buffer_t  *buffer);
 
+HB_INTERNAL void _hb_ot_shape_fallback_position_recategorize_marks (const hb_ot_shape_plan_t *plan,
+								    hb_font_t *font,
+								    hb_buffer_t  *buffer);
+
+
 #endif /* HB_OT_SHAPE_FALLBACK_PRIVATE_HH */
diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc
index abacfa3..b88fa83 100644
--- a/src/hb-ot-shape-fallback.cc
+++ b/src/hb-ot-shape-fallback.cc
@@ -26,21 +26,9 @@
 
 #include "hb-ot-shape-fallback-private.hh"
 
-static void
-zero_mark_advances (hb_buffer_t *buffer,
-		    unsigned int start,
-		    unsigned int end)
-{
-  for (unsigned int i = start; i < end; i++)
-    if (_hb_glyph_info_get_general_category (&buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
-    {
-      buffer->pos[i].x_advance = 0;
-      buffer->pos[i].y_advance = 0;
-    }
-}
-
 static unsigned int
-recategorize_combining_class (unsigned int modified_combining_class)
+recategorize_combining_class (hb_codepoint_t u,
+			      unsigned int modified_combining_class)
 {
   if (modified_combining_class >= 200)
     return modified_combining_class;
@@ -136,6 +124,34 @@ recategorize_combining_class (unsigned int modified_combining_class)
   return modified_combining_class;
 }
 
+void
+_hb_ot_shape_fallback_position_recategorize_marks (const hb_ot_shape_plan_t *plan,
+						   hb_font_t *font,
+						   hb_buffer_t  *buffer)
+{
+  unsigned int count = buffer->len;
+  for (unsigned int i = 0; i < count; i++)
+    if (_hb_glyph_info_get_general_category (&buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) {
+      unsigned int combining_class = _hb_glyph_info_get_modified_combining_class (&buffer->info[i]);
+      combining_class = recategorize_combining_class (buffer->info[i].codepoint, combining_class);
+      _hb_glyph_info_set_modified_combining_class (&buffer->info[i], combining_class);
+    }
+}
+
+
+static void
+zero_mark_advances (hb_buffer_t *buffer,
+		    unsigned int start,
+		    unsigned int end)
+{
+  for (unsigned int i = start; i < end; i++)
+    if (_hb_glyph_info_get_general_category (&buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
+    {
+      buffer->pos[i].x_advance = 0;
+      buffer->pos[i].y_advance = 0;
+    }
+}
+
 static inline void
 position_mark (const hb_ot_shape_plan_t *plan,
 	       hb_font_t *font,
@@ -259,7 +275,7 @@ position_around_base (const hb_ot_shape_plan_t *plan,
   for (unsigned int i = base + 1; i < end; i++)
     if (_hb_glyph_info_get_modified_combining_class (&buffer->info[i]))
     {
-      unsigned int this_combining_class = recategorize_combining_class (_hb_glyph_info_get_modified_combining_class (&buffer->info[i]));
+      unsigned int this_combining_class = _hb_glyph_info_get_modified_combining_class (&buffer->info[i]);
       if (this_combining_class != last_combining_class)
         cluster_extents = base_extents;
 
diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh
index f856045..c4c368d 100644
--- a/src/hb-ot-shape-private.hh
+++ b/src/hb-ot-shape-private.hh
@@ -95,6 +95,12 @@ _hb_glyph_info_get_general_category (const hb_glyph_info_t *info)
   return (hb_unicode_general_category_t) (info->unicode_props0() & 0x7F);
 }
 
+inline void
+_hb_glyph_info_set_modified_combining_class (hb_glyph_info_t *info, unsigned int modified_class)
+{
+  info->unicode_props1() = modified_class;
+}
+
 inline unsigned int
 _hb_glyph_info_get_modified_combining_class (const hb_glyph_info_t *info)
 {
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 929406e..26b21ce 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -345,6 +345,10 @@ hb_ot_substitute_default (hb_ot_shape_context_t *c)
 
   hb_ot_shape_setup_masks (c);
 
+  /* This is unfortunate to go here, but necessary... */
+  if (!hb_ot_layout_has_positioning (c->face))
+    _hb_ot_shape_fallback_position_recategorize_marks (c->plan, c->font, c->buffer);
+
   hb_ot_map_glyphs_fast (c->buffer);
 
   HB_BUFFER_DEALLOCATE_VAR (c->buffer, glyph_index);



More information about the HarfBuzz mailing list