From 80ea5bd10e72561a7627a5196621a6d7eccd91b7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 26 May 2009 17:58:37 -0400 Subject: [PATCH] [GPOS] Fix mark matching --- src/hb-ot-layout-gpos-private.h | 44 +++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/hb-ot-layout-gpos-private.h b/src/hb-ot-layout-gpos-private.h index e115cd4..e2057c2 100644 --- a/src/hb-ot-layout-gpos-private.h +++ b/src/hb-ot-layout-gpos-private.h @@ -778,19 +778,16 @@ struct MarkBasePosFormat1 /* now we search backwards for a non-mark glyph */ unsigned int count = buffer->in_pos; unsigned int i = 1, j = count - 1; - while (i <= count) + while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), LookupFlag::IgnoreMarks, NULL)) { - property = _hb_ot_layout_get_glyph_property (layout, IN_GLYPH (j)); - if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)) - break; + if (HB_UNLIKELY (i == count)) + return false; i++, j--; } - if (HB_UNLIKELY (i > buffer->in_pos)) - return false; - /* The following assertion is too strong -- at least for mangal.ttf. */ #if 0 - if (property != HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH) + /* The following assertion is too strong. */ + if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH)) return false; #endif @@ -900,19 +897,16 @@ struct MarkLigPosFormat1 /* now we search backwards for a non-mark glyph */ unsigned int count = buffer->in_pos; unsigned int i = 1, j = count - 1; - while (i <= count) + while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), LookupFlag::IgnoreMarks, NULL)) { - property = _hb_ot_layout_get_glyph_property (layout, IN_GLYPH (j)); - if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)) - break; + if (HB_UNLIKELY (i == count)) + return false; i++, j--; } - if (HB_UNLIKELY (i > buffer->in_pos)) - return false; - /* The following assertion is too strong -- at least for mangal.ttf. */ #if 0 - if (property != HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE) + /* The following assertion is too strong. */ + if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)) return false; #endif @@ -1035,17 +1029,19 @@ struct MarkMarkPosFormat1 /* now we search backwards for a suitable mark glyph until a non-mark glyph */ unsigned int count = buffer->in_pos; unsigned int i = 1, j = count - 1; - while (i <= count) + while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, NULL)) { - property = _hb_ot_layout_get_glyph_property (layout, IN_GLYPH (j)); - if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)) - return false; - if (!(lookup_flag & LookupFlag::MarkAttachmentType) || - (lookup_flag & LookupFlag::MarkAttachmentType) == property) - break; + if (HB_UNLIKELY (i == count)) + return false; i++, j--; } - if (HB_UNLIKELY (i > buffer->in_pos)) + if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)) + return false; + + /* Two marks match only if they belong to the same base, or same component + * of the same ligature. */ + if (IN_LIGID (j) != IN_LIGID (buffer->in_pos) || + IN_COMPONENT (j) != IN_COMPONENT (buffer->in_pos)) return false; unsigned int mark2_index = (this+mark2Coverage) (IN_GLYPH (j)); -- 2.7.4