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

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Jun 12 15:35:44 PDT 2014


 src/hb-ot-shape-complex-thai.cc |    5 +++-
 src/hb-ot-shape.cc              |   50 +++++++++++++++++++++++++++++++---------
 2 files changed, 43 insertions(+), 12 deletions(-)

New commits:
commit 798e4185bc71b1a63528e6b0af236d4c964ec607
Author: Jonathan Kew <jfkthame at gmail.com>
Date:   Tue Jun 10 13:10:30 2014 +0100

    When zeroing mark widths for LTR, also adjust offset...
    
    ...so that they overstrike preceding glyph.
    
    https://github.com/behdad/harfbuzz/pull/43

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 3080a1d..42f68ab 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -452,26 +452,42 @@ hb_ot_substitute (hb_ot_shape_context_t *c)
 /* Position */
 
 static inline void
-zero_mark_widths_by_unicode (hb_buffer_t *buffer)
+adjust_mark_offsets (hb_glyph_position_t *pos)
+{
+  pos->x_offset -= pos->x_advance;
+  pos->y_offset -= pos->y_advance;
+}
+
+static inline void
+zero_mark_width (hb_glyph_position_t *pos)
+{
+  pos->x_advance = 0;
+  pos->y_advance = 0;
+}
+
+static inline void
+zero_mark_widths_by_unicode (hb_buffer_t *buffer, bool adjust_offsets)
 {
   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)
     {
-      buffer->pos[i].x_advance = 0;
-      buffer->pos[i].y_advance = 0;
+      if (adjust_offsets)
+        adjust_mark_offsets (&buffer->pos[i]);
+      zero_mark_width (&buffer->pos[i]);
     }
 }
 
 static inline void
-zero_mark_widths_by_gdef (hb_buffer_t *buffer)
+zero_mark_widths_by_gdef (hb_buffer_t *buffer, bool adjust_offsets)
 {
   unsigned int count = buffer->len;
   for (unsigned int i = 0; i < count; i++)
     if (_hb_glyph_info_is_mark (&buffer->info[i]))
     {
-      buffer->pos[i].x_advance = 0;
-      buffer->pos[i].y_advance = 0;
+      if (adjust_offsets)
+        adjust_mark_offsets (&buffer->pos[i]);
+      zero_mark_width (&buffer->pos[i]);
     }
 }
 
@@ -501,16 +517,28 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
 {
   bool ret = false;
   unsigned int count = c->buffer->len;
+  bool has_positioning = hb_ot_layout_has_positioning (c->face);
+  /* If the font has no GPOS, AND, no fallback positioning will
+   * happen, AND, direction is forward, then when zeroing mark
+   * widths, we shift the mark with it, such that the mark
+   * is positioned hanging over the previous glyph.  When
+   * direction is backward we don't shift and it will end up
+   * hanging over the next glyph after the final reordering.
+   * If fallback positinoing happens or GPOS is present, we don't
+   * care.
+   */
+  bool adjust_offsets_when_zeroing = !(has_positioning || c->plan->shaper->fallback_position ||
+                                       HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction));
 
   switch (c->plan->shaper->zero_width_marks)
   {
     case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY:
-      zero_mark_widths_by_gdef (c->buffer);
+      zero_mark_widths_by_gdef (c->buffer, adjust_offsets_when_zeroing);
       break;
 
     /* Not currently used for any shaper:
     case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE_EARLY:
-      zero_mark_widths_by_unicode (c->buffer);
+      zero_mark_widths_by_unicode (c->buffer, adjust_offsets_when_zeroing);
       break;
     */
 
@@ -521,7 +549,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
       break;
   }
 
-  if (hb_ot_layout_has_positioning (c->face))
+  if (has_positioning)
   {
     hb_glyph_info_t *info = c->buffer->info;
     hb_glyph_position_t *pos = c->buffer->pos;
@@ -550,11 +578,11 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
   switch (c->plan->shaper->zero_width_marks)
   {
     case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE_LATE:
-      zero_mark_widths_by_unicode (c->buffer);
+      zero_mark_widths_by_unicode (c->buffer, adjust_offsets_when_zeroing);
       break;
 
     case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE:
-      zero_mark_widths_by_gdef (c->buffer);
+      zero_mark_widths_by_gdef (c->buffer, adjust_offsets_when_zeroing);
       break;
 
     default:
commit 80f7405a5208f88b8615aa4ce4c54ffeb16f04f8
Author: Jonathan Kew <jfkthame at gmail.com>
Date:   Tue Jun 10 13:10:02 2014 +0100

    [Thai] set the correct general category on Nikhahit when decomposing Sara-Am.

diff --git a/src/hb-ot-shape-complex-thai.cc b/src/hb-ot-shape-complex-thai.cc
index 8664eca..cb9a7d9 100644
--- a/src/hb-ot-shape-complex-thai.cc
+++ b/src/hb-ot-shape-complex-thai.cc
@@ -330,8 +330,11 @@ preprocess_text_thai (const hb_ot_shape_plan_t *plan,
     if (unlikely (buffer->in_error))
       return;
 
-    /* Ok, let's see... */
+    /* Make Nikhahit be recognized as a mark when zeroing widths. */
     unsigned int end = buffer->out_len;
+    _hb_glyph_info_set_general_category (&buffer->out_info[end - 2], HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK);
+
+    /* Ok, let's see... */
     unsigned int start = end - 2;
     while (start > 0 && IS_TONE_MARK (buffer->out_info[start - 1].codepoint))
       start--;


More information about the HarfBuzz mailing list