Further adjust mark advance zeroing
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 13 Feb 2013 10:57:24 +0000 (05:57 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 13 Feb 2013 10:57:24 +0000 (05:57 -0500)
This is a followup to 568000274c8edb5f41bc4f876ce21fcc8bdaeed8.
Looks like in the Latin shaper, Uniscribe zeroes all Unicode NSM
advances *after* GPOS, not before.  Match that.

Can be tested using DejaVu Sans Mono, since that font has GPOS
rules to zero the mark advances on its own.

src/hb-ot-shape.cc

index ce13139..d529223 100644 (file)
@@ -418,17 +418,10 @@ hb_ot_position_default (hb_ot_shape_context_t *c)
 
   }
 
+  /* Zero'ing mark widths by GDEF (as used in Myanmar spec) happens
+   * *before* GPOS. */
   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))
@@ -440,6 +433,7 @@ hb_ot_position_default (hb_ot_shape_context_t *c)
 
     default:
     case HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE:
+    case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE:
       break;
   }
 }
@@ -448,12 +442,12 @@ static inline bool
 hb_ot_position_complex (hb_ot_shape_context_t *c)
 {
   bool ret = false;
+  unsigned int count = c->buffer->len;
 
   if (hb_ot_layout_has_positioning (c->face))
   {
     /* Change glyph origin to what GPOS expects, apply GPOS, change it back. */
 
-    unsigned int count = c->buffer->len;
     for (unsigned int i = 0; i < count; i++) {
       c->font->add_glyph_origin_for_direction (c->buffer->info[i].codepoint,
                                               HB_DIRECTION_LTR,
@@ -473,6 +467,25 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
     ret = true;
   }
 
+  /* Zero'ing mark widths by Unicode happens
+   * *after* GPOS. */
+  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;
+
+    default:
+    case HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE:
+    case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF:
+      break;
+  }
+
   hb_ot_layout_position_finish (c->font, c->buffer);
 
   return ret;