[GPOS] Adjust mark advance-width zeroing logic
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 1 Aug 2012 03:41:06 +0000 (23:41 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 1 Aug 2012 03:41:06 +0000 (23:41 -0400)
If there is no GPOS, zero mark advances.

If there *is* GPOS and the shaper requests so, zero mark advances for
attached marks.

Fixes regression with Tibetan, where the font has GPOS, and marks a
glyph as mark where it shouldn't get zero advance.

src/hb-ot-layout-gpos-table.hh
src/hb-ot-layout.cc
src/hb-ot-layout.h
src/hb-ot-shape-complex-arabic.cc
src/hb-ot-shape-complex-indic.cc
src/hb-ot-shape-complex-misc.cc
src/hb-ot-shape-complex-private.hh
src/hb-ot-shape.cc

index 339749e..2e8a389 100644 (file)
@@ -1587,7 +1587,7 @@ struct GPOS : GSUBGPOS
   { return get_lookup (lookup_index).apply_string (c); }
 
   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);
+  static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t zero_width_attahced_marks);
 
   inline bool sanitize (hb_sanitize_context_t *c) {
     TRACE_SANITIZE ();
@@ -1620,15 +1620,17 @@ 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)
+fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction, hb_bool_t zero_width_attached_marks)
 {
   if (likely (!(pos[i].attach_lookback())))
     return;
 
   unsigned int j = i - pos[i].attach_lookback();
 
-//  pos[i].x_advance = 0;
-//  pos[i].y_advance = 0;
+  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;
 
@@ -1655,7 +1657,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)
+GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer, hb_bool_t zero_width_attached_marks)
 {
   unsigned int len;
   hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &len);
@@ -1667,7 +1669,7 @@ GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
 
   /* Handle attachments */
   for (unsigned int i = 0; i < len; i++)
-    fix_mark_attachment (pos, i, direction);
+    fix_mark_attachment (pos, i, direction, zero_width_attached_marks);
 
   HB_BUFFER_DEALLOCATE_VAR (buffer, syllable);
   HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props);
index 28c2f83..0d0dfa0 100644 (file)
@@ -478,9 +478,9 @@ hb_ot_layout_position_lookup_fast (hb_font_t    *font,
 }
 
 void
-hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer)
+hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t zero_width_attached_marks)
 {
-  GPOS::position_finish (font, buffer);
+  GPOS::position_finish (font, buffer, zero_width_attached_marks);
 }
 
 
index 4e205d7..d663ab0 100644 (file)
@@ -219,7 +219,8 @@ hb_ot_layout_position_lookup (hb_font_t    *font,
 /* Should be called after all the position_lookup's are done */
 void
 hb_ot_layout_position_finish (hb_font_t    *font,
-                             hb_buffer_t  *buffer);
+                             hb_buffer_t  *buffer,
+                             hb_bool_t     zero_width_attached_marks);
 
 
 HB_END_DECLS
index 2cff581..39b25c3 100644 (file)
@@ -299,5 +299,5 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic =
   NULL, /* override_features */
   NULL, /* normalization_preference */
   setup_masks_arabic,
-  true, /* zero_width_marks */
+  true, /* zero_width_attached_marks */
 };
index ba51821..15af692 100644 (file)
@@ -1245,5 +1245,5 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_indic =
   override_features_indic,
   NULL, /* normalization_preference */
   setup_masks_indic,
-  false, /* zero_width_marks */
+  false, /* zero_width_attached_marks */
 };
index 015ee08..a9dda94 100644 (file)
@@ -93,7 +93,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default =
   NULL, /* override_features */
   normalization_preference_default,
   NULL, /* setup_masks */
-  true, /* zero_width_marks */
+  true, /* zero_width_attached_marks */
 };
 
 
@@ -202,5 +202,5 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_thai =
   NULL, /* override_features */
   NULL, /* normalization_preference */
   setup_masks_thai,
-  true, /* zero_width_marks */
+  true, /* zero_width_attached_marks */
 };
index 8ef41e8..9cdafff 100644 (file)
@@ -94,7 +94,7 @@ struct hb_ot_complex_shaper_t
                       hb_buffer_t                  *buffer,
                       hb_font_t                    *font);
 
-  bool zero_width_marks;
+  bool zero_width_attached_marks;
 };
 
 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) extern HB_INTERNAL const hb_ot_complex_shaper_t _hb_ot_complex_shaper_##name;
index ac15b2a..11bc74f 100644 (file)
@@ -439,12 +439,10 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
     }
 
     c->applied_position_complex = true;
-  }
-
-  if (c->plan->shaper->zero_width_marks)
+  } else
     hb_zero_mark_advances (c);
 
-  hb_ot_layout_position_finish (c->font, c->buffer);
+  hb_ot_layout_position_finish (c->font, c->buffer, c->plan->shaper->zero_width_attached_marks);
 
   return;
 }