[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.
This commit is contained in:
Behdad Esfahbod 2012-07-31 23:41:06 -04:00
parent a8842e4a44
commit 1e7d860613
8 changed files with 19 additions and 18 deletions

View 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);

View 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);
}

View 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

View 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 */
};

View 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 */
};

View 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 */
};

View 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;

View 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;
}