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

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Feb 12 06:49:01 PST 2013


 src/hb-atomic-private.hh                   |    2 -
 src/hb-mutex-private.hh                    |    2 -
 src/hb-ot-layout-gpos-table.hh             |   12 ++-----
 src/hb-ot-layout-private.hh                |    3 -
 src/hb-ot-layout.cc                        |    4 +-
 src/hb-ot-shape-complex-arabic.cc          |    2 -
 src/hb-ot-shape-complex-default.cc         |    2 -
 src/hb-ot-shape-complex-indic.cc           |    2 -
 src/hb-ot-shape-complex-myanmar-machine.rl |    6 +--
 src/hb-ot-shape-complex-myanmar.cc         |   47 +++++++++++++++++++++++++++--
 src/hb-ot-shape-complex-private.hh         |    9 ++++-
 src/hb-ot-shape-complex-thai.cc            |    2 -
 src/hb-ot-shape.cc                         |   31 +++++++++++++++++--
 13 files changed, 96 insertions(+), 28 deletions(-)

New commits:
commit 568000274c8edb5f41bc4f876ce21fcc8bdaeed8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Feb 12 09:44:57 2013 -0500

    Adjust mark advance-width zeroing logic for Myanmar
    
    Before, we were zeroing advance width of attached marks for
    non-Indic scripts, and not doing it for Indic.
    
    We have now three different behaviors, which seem to better
    reflect what Uniscribe is doing:
    
      - For Indic, no explicit zeroing happens whatsoever, which
        is the same as before,
    
      - For Myanmar, zero advance width of glyphs marked as marks
        *in GDEF*, and do that *before* applying GPOS.  This seems
        to be what the new Win8 Myanmar shaper does,
    
      - For everything else, zero advance width of glyphs that are
        from General_Category=Mn Unicode characters, and do so
        before applying GPOS.  This seems to be what Uniscribe does
        for Latin at least.
    
    With these changes, positioning of all tests matches for Myanmar,
    except for the glitch in Uniscribe not applying 'mark'.  See preivous
    commit.

diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 148a57c..59d818e 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1528,7 +1528,7 @@ struct GPOS : GSUBGPOS
   { return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); }
 
   static inline void position_start (hb_font_t *font, hb_buffer_t *buffer);
-  static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t zero_width_attahced_marks);
+  static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer);
 
   inline bool sanitize (hb_sanitize_context_t *c) {
     TRACE_SANITIZE (this);
@@ -1561,17 +1561,13 @@ fix_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direction
 }
 
 static void
-fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction, hb_bool_t zero_width_attached_marks)
+fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction)
 {
   if (likely (!(pos[i].attach_lookback())))
     return;
 
   unsigned int j = i - pos[i].attach_lookback();
 
-  if (zero_width_attached_marks) {
-    pos[i].x_advance = 0;
-    pos[i].y_advance = 0;
-  }
   pos[i].x_offset += pos[j].x_offset;
   pos[i].y_offset += pos[j].y_offset;
 
@@ -1598,7 +1594,7 @@ GPOS::position_start (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
 }
 
 void
-GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer, hb_bool_t zero_width_attached_marks)
+GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
 {
   unsigned int len;
   hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &len);
@@ -1610,7 +1606,7 @@ GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer, hb_bool_t
 
   /* Handle attachments */
   for (unsigned int i = 0; i < len; i++)
-    fix_mark_attachment (pos, i, direction, zero_width_attached_marks);
+    fix_mark_attachment (pos, i, direction);
 
   HB_BUFFER_DEALLOCATE_VAR (buffer, syllable);
   HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props);
diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh
index 49093de..b550fa8 100644
--- a/src/hb-ot-layout-private.hh
+++ b/src/hb-ot-layout-private.hh
@@ -176,8 +176,7 @@ hb_ot_layout_position_lookup (hb_font_t    *font,
 /* Should be called after all the position_lookup's are done */
 HB_INTERNAL void
 hb_ot_layout_position_finish (hb_font_t    *font,
-			      hb_buffer_t  *buffer,
-			      hb_bool_t     zero_width_attached_marks);
+			      hb_buffer_t  *buffer);
 
 
 
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 3ff6fc8..291ff9a 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -727,9 +727,9 @@ hb_ot_layout_position_lookup (hb_font_t    *font,
 }
 
 void
-hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t zero_width_attached_marks)
+hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer)
 {
-  OT::GPOS::position_finish (font, buffer, zero_width_attached_marks);
+  OT::GPOS::position_finish (font, buffer);
 }
 
 hb_bool_t
diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index 35356fe..3374cfc 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -354,6 +354,6 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic =
   NULL, /* decompose */
   NULL, /* compose */
   setup_masks_arabic,
-  true, /* zero_width_attached_marks */
+  HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE,
   true, /* fallback_position */
 };
diff --git a/src/hb-ot-shape-complex-default.cc b/src/hb-ot-shape-complex-default.cc
index 5340293..d406f8c 100644
--- a/src/hb-ot-shape-complex-default.cc
+++ b/src/hb-ot-shape-complex-default.cc
@@ -221,6 +221,6 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default =
   NULL, /* decompose */
   compose_default,
   NULL, /* setup_masks */
-  true, /* zero_width_attached_marks */
+  HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE,
   true, /* fallback_position */
 };
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 573443f..9c704fb 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -1404,6 +1404,6 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_indic =
   decompose_indic,
   compose_indic,
   setup_masks_indic,
-  false, /* zero_width_attached_marks */
+  HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
   false, /* fallback_position */
 };
diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc
index 7cae6ff..5adcdfc 100644
--- a/src/hb-ot-shape-complex-myanmar.cc
+++ b/src/hb-ot-shape-complex-myanmar.cc
@@ -635,6 +635,6 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar =
   NULL, /* decompose */
   NULL, /* compose */
   setup_masks_myanmar,
-  false, /* zero_width_attached_marks */
+  HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF,
   false, /* fallback_position */
 };
diff --git a/src/hb-ot-shape-complex-private.hh b/src/hb-ot-shape-complex-private.hh
index a0d4e4b..6b562fc 100644
--- a/src/hb-ot-shape-complex-private.hh
+++ b/src/hb-ot-shape-complex-private.hh
@@ -39,6 +39,12 @@
 #define complex_var_u8_1()	var2.u8[3]
 
 
+enum hb_ot_shape_zero_width_marks_type_t {
+  HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
+  HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE,
+  HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF
+};
+
 
 /* Master OT shaper list */
 #define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \
@@ -131,7 +137,8 @@ struct hb_ot_complex_shaper_t
 		       hb_buffer_t              *buffer,
 		       hb_font_t                *font);
 
-  bool zero_width_attached_marks;
+  hb_ot_shape_zero_width_marks_type_t zero_width_marks;
+
   bool fallback_position;
 };
 
diff --git a/src/hb-ot-shape-complex-thai.cc b/src/hb-ot-shape-complex-thai.cc
index 24d476a..5cbb6e3 100644
--- a/src/hb-ot-shape-complex-thai.cc
+++ b/src/hb-ot-shape-complex-thai.cc
@@ -373,6 +373,6 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_thai =
   NULL, /* decompose */
   NULL, /* compose */
   NULL, /* setup_masks */
-  true, /* zero_width_attached_marks */
+  HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE,
   false,/* fallback_position */
 };
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 96461d7..ce13139 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -405,7 +405,8 @@ hb_ot_position_default (hb_ot_shape_context_t *c)
   hb_ot_layout_position_start (c->font, c->buffer);
 
   unsigned int count = c->buffer->len;
-  for (unsigned int i = 0; i < count; i++) {
+  for (unsigned int i = 0; i < count; i++)
+  {
     c->font->get_glyph_advance_for_direction (c->buffer->info[i].codepoint,
 					      c->buffer->props.direction,
 					      &c->buffer->pos[i].x_advance,
@@ -414,6 +415,32 @@ hb_ot_position_default (hb_ot_shape_context_t *c)
 						  c->buffer->props.direction,
 						  &c->buffer->pos[i].x_offset,
 						  &c->buffer->pos[i].y_offset);
+
+  }
+
+  switch (c->plan->shaper->zero_width_marks)
+  {
+    case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE:
+      for (unsigned int i = 0; i < count; i++)
+	if (_hb_glyph_info_get_general_category (&c->buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
+	{
+	  c->buffer->pos[i].x_advance = 0;
+	  c->buffer->pos[i].y_advance = 0;
+	}
+      break;
+
+    case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF:
+      for (unsigned int i = 0; i < count; i++)
+	if ((c->buffer->info[i].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK))
+	{
+	  c->buffer->pos[i].x_advance = 0;
+	  c->buffer->pos[i].y_advance = 0;
+	}
+      break;
+
+    default:
+    case HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE:
+      break;
   }
 }
 
@@ -446,7 +473,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
     ret = true;
   }
 
-  hb_ot_layout_position_finish (c->font, c->buffer, c->plan->shaper->zero_width_attached_marks);
+  hb_ot_layout_position_finish (c->font, c->buffer);
 
   return ret;
 }
commit 99749ca8e0c4c8dbea4620f07c4d0e6d1515cc65
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Feb 12 09:44:35 2013 -0500

    [Myanmar] Add note re Uniscribe NOT applying 'mark'

diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc
index e31ed03..7cae6ff 100644
--- a/src/hb-ot-shape-complex-myanmar.cc
+++ b/src/hb-ot-shape-complex-myanmar.cc
@@ -120,6 +120,20 @@ static void
 override_features_myanmar (hb_ot_shape_planner_t *plan)
 {
   plan->map.add_feature (HB_TAG('l','i','g','a'), 0, true);
+
+  /*
+   * Note:
+   *
+   * Spec says 'mark' is used, and the mmrtext.ttf font from
+   * Windows 8 has lookups for it.  But testing suggests that
+   * Windows 8 Uniscribe is NOT applying it.  It *is* applying
+   * 'mkmk' however.
+   *
+   * We want to apply it, since that's the right thing to do.
+   */
+#if 0
+  plan->map.add_feature (HB_TAG('m','a','r','k'), 0, true);
+#endif
 }
 
 
commit b8427801381180da9611b2e3e0f0b3514274de81
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Feb 11 17:02:17 2013 -0500

    Minor

diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh
index b909bc8..c7456e0 100644
--- a/src/hb-atomic-private.hh
+++ b/src/hb-atomic-private.hh
@@ -42,7 +42,7 @@
 #if 0
 
 
-#elif !defined(HB_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__)
+#elif !defined(HB_NO_MT) && (defined(_MSC_VER) || defined(__MINGW32__))
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
diff --git a/src/hb-mutex-private.hh b/src/hb-mutex-private.hh
index 5b3a17e..fcbdb31 100644
--- a/src/hb-mutex-private.hh
+++ b/src/hb-mutex-private.hh
@@ -42,7 +42,7 @@
 #if 0
 
 
-#elif !defined(HB_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__)
+#elif !defined(HB_NO_MT) && (defined(_MSC_VER) || defined(__MINGW32__))
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
commit 419c933ed1b5d97c7561546536ef5810a7b0ebd0
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Feb 11 16:16:16 2013 -0500

    [Myanmar] Fix handling of Punctuation and Symbol types
    
    Testing with "clusters" now on par with testing without them.  15
    failures both.

diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc
index 8988da9..e31ed03 100644
--- a/src/hb-ot-shape-complex-myanmar.cc
+++ b/src/hb-ot-shape-complex-myanmar.cc
@@ -232,6 +232,18 @@ set_myanmar_properties (hb_glyph_info_t &info)
     cat = OT_VS;
   switch (u)
   {
+    case 0x104A: case 0x104B:
+      /* Punctuation; don't care. */
+      cat = OT_X;
+      break;
+
+    case 0x104C: case 0x104D: case 0x104F: case 0x109E:
+    case 0x109F: case 0xAA70: case 0xAA77: case 0xAA78:
+    case 0xAA79:
+      /* Symbols; don't care. */
+      cat = OT_X;
+      break;
+
     case 0x002D: case 0x00A0: case 0x00D7: case 0x2012:
     case 0x2013: case 0x2014: case 0x2015: case 0x2022:
     case 0x25CC: case 0x25FB: case 0x25FC: case 0x25FD:
commit 0572c1410a9cb0ac5dd5dc84a8034698cc5c4892
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Feb 11 16:06:02 2013 -0500

    [Myanmar] Fixup handling of joiners and GB characters

diff --git a/src/hb-ot-shape-complex-myanmar-machine.rl b/src/hb-ot-shape-complex-myanmar-machine.rl
index 5db39bf..949fde6 100644
--- a/src/hb-ot-shape-complex-myanmar-machine.rl
+++ b/src/hb-ot-shape-complex-myanmar-machine.rl
@@ -44,8 +44,7 @@ C    = 1;
 D    = 19;
 D0   = 20;
 DB   = 3;
-DOTTEDCIRCLE = 12;
-NBSP = 11;
+GB   = 12;
 H    = 4;
 IV   = 2;
 MH   = 21;
@@ -63,7 +62,6 @@ ZWJ  = 6;
 ZWNJ = 5;
 Ra   = 16;
 
-gb = (DOTTEDCIRCLE | NBSP);	# Generic base characters
 j = ZWJ|ZWNJ;			# Joiners
 k = (Ra As H);			# Kinzi
 
@@ -77,7 +75,7 @@ pwo_tone_group = PT A* (DB As?)?;
 complex_syllable_tail = As* medial_group main_vowel_group post_vowel_group* pwo_tone_group* V* j?;
 syllable_tail = (H | complex_syllable_tail);
 
-consonant_syllable =	k? (c|IV|D|gb).VS? (H (c|IV).VS?)* syllable_tail;
+consonant_syllable =	k? (c|IV|D|GB).VS? (H (c|IV).VS?)* syllable_tail;
 broken_cluster =	k? VS? syllable_tail;
 other =			any;
 
diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc
index 2f81e45..8988da9 100644
--- a/src/hb-ot-shape-complex-myanmar.cc
+++ b/src/hb-ot-shape-complex-myanmar.cc
@@ -146,7 +146,7 @@ enum myanmar_category_t {
   OT_SM   = 8,
   OT_A    = 10,
   OT_NBSP = 11,
-  OT_DOTTEDCIRCLE = 12, /* Not in the spec, but special in Uniscribe. /Very very/ special! */
+  OT_GB = 12,
 
   OT_Ra = 16, /* Not explicitly listed in the OT spec, but used in the grammar. */
   OT_CM = 17, /* Generic Consonant_Medial; NOT used for Myanmar. */
@@ -210,7 +210,7 @@ is_one_of (const hb_glyph_info_t &info, unsigned int flags)
  * We treat Vowels and placeholders as if they were consonants.  This is safe because Vowels
  * cannot happen in a consonant syllable.  The plus side however is, we can call the
  * consonant syllable logic from the vowel syllable function and get it all right! */
-#define CONSONANT_FLAGS (FLAG (OT_C) | FLAG (OT_CM) | FLAG (OT_Ra) | FLAG (OT_V) | FLAG (OT_NBSP) | FLAG (OT_DOTTEDCIRCLE))
+#define CONSONANT_FLAGS (FLAG (OT_C) | FLAG (OT_CM) | FLAG (OT_Ra) | FLAG (OT_V) | FLAG (OT_NBSP) | FLAG (OT_GB))
 static inline bool
 is_consonant (const hb_glyph_info_t &info)
 {
@@ -232,6 +232,21 @@ set_myanmar_properties (hb_glyph_info_t &info)
     cat = OT_VS;
   switch (u)
   {
+    case 0x002D: case 0x00A0: case 0x00D7: case 0x2012:
+    case 0x2013: case 0x2014: case 0x2015: case 0x2022:
+    case 0x25CC: case 0x25FB: case 0x25FC: case 0x25FD:
+    case 0x25FE:
+      cat = OT_GB;
+      break;
+
+    case 0x200C:
+      cat = OT_ZWNJ;
+      break;
+
+    case 0x200D:
+      cat = OT_ZWJ;
+      break;
+
     case 0x1004: case 0x101B: case 0x105A:
       cat = OT_Ra;
       break;



More information about the HarfBuzz mailing list