From 1e7d860613032e40a3f90e2caa2ee5ac44ab8c8c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 31 Jul 2012 23:41:06 -0400 Subject: [PATCH] [GPOS] Adjust mark advance-width zeroing logic 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 | 14 ++++++++------ src/hb-ot-layout.cc | 4 ++-- src/hb-ot-layout.h | 3 ++- src/hb-ot-shape-complex-arabic.cc | 2 +- src/hb-ot-shape-complex-indic.cc | 2 +- src/hb-ot-shape-complex-misc.cc | 4 ++-- src/hb-ot-shape-complex-private.hh | 2 +- src/hb-ot-shape.cc | 6 ++---- 8 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 339749ed6..2e8a389d0 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -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); diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 28c2f8325..0d0dfa0b5 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -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); } diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h index 4e205d71d..d663ab0b2 100644 --- a/src/hb-ot-layout.h +++ b/src/hb-ot-layout.h @@ -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 diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 2cff581eb..39b25c385 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -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 */ }; diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index ba5182105..15af69224 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -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 */ }; diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc index 015ee0839..a9dda94c9 100644 --- a/src/hb-ot-shape-complex-misc.cc +++ b/src/hb-ot-shape-complex-misc.cc @@ -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 */ }; diff --git a/src/hb-ot-shape-complex-private.hh b/src/hb-ot-shape-complex-private.hh index 8ef41e890..9cdafff25 100644 --- a/src/hb-ot-shape-complex-private.hh +++ b/src/hb-ot-shape-complex-private.hh @@ -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; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index ac15b2ae0..11bc74f61 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -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; }