[GPOS] Fix mark-to-mark positioning when one of the marks is a ligature
authorBehdad Esfahbod <behdad@behdad.org>
Sun, 29 Jul 2012 01:05:25 +0000 (21:05 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Sun, 29 Jul 2012 01:05:25 +0000 (21:05 -0400)
This commit: a3313e54008167e415b72c780ca7b9cda958d07e broke MarkMarkPos
when one of the marks itself is a ligature.  That regressed 26 Tibetan
tests (up from zero!).  Fix that.  Tibetan back to zero.

src/hb-ot-layout-gpos-table.hh
src/hb-ot-layout-private.hh
test/shaping/texts/in-tree/shaper-indic/MANIFEST
test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/MANIFEST
test/shaping/texts/in-tree/shaper-indic/south-asian/MANIFEST [new file with mode: 0644]
test/shaping/texts/in-tree/shaper-indic/south-asian/script-tibetan/MANIFEST [new file with mode: 0644]
test/shaping/texts/in-tree/shaper-indic/south-asian/script-tibetan/misc/MANIFEST [new file with mode: 0644]
test/shaping/texts/in-tree/shaper-indic/south-asian/script-tibetan/misc/misc.txt [new file with mode: 0644]

index 3b1ae2a..83252c1 100644 (file)
@@ -1263,14 +1263,27 @@ struct MarkMarkPosFormat1
 
     unsigned int j = skippy_iter.idx;
 
-    /* Two marks match only if they belong to the same base, or same component
-     * of the same ligature.  That is, the lig_id numbers must match, and
-     * if those are non-zero, the lig_comp number should also match. */
-    if ((get_lig_id (c->buffer->info[j]) != get_lig_id (c->buffer->cur())) ||
-       (get_lig_id (c->buffer->info[j]) > 0 &&
-        get_lig_comp (c->buffer->info[j]) != get_lig_comp (c->buffer->cur())))
-      return TRACE_RETURN (false);
+    unsigned int id1 = get_lig_id (c->buffer->cur());
+    unsigned int id2 = get_lig_id (c->buffer->info[j]);
+    unsigned int comp1 = get_lig_comp (c->buffer->cur());
+    unsigned int comp2 = get_lig_comp (c->buffer->info[j]);
+
+    if (likely (id1 == id2)) {
+      if (id1 == 0) /* Marks belonging to the same base. */
+       goto good;
+      else if (comp1 == comp2) /* Marks belonging to the same ligature component. */
+        goto good;
+    } else {
+      /* If ligature ids don't match, it may be the case that one of the marks
+       * itself is a ligature.  In which case match. */
+      if ((id1 > 0 && !comp1) || (id2 > 0 && !comp2))
+       goto good;
+    }
+
+    /* Didn't match. */
+    return TRACE_RETURN (false);
 
+    good:
     unsigned int mark2_index = (this+mark2Coverage) (c->buffer->info[j].codepoint);
     if (mark2_index == NOT_COVERED) return TRACE_RETURN (false);
 
index 294c359..1c108e0 100644 (file)
@@ -73,7 +73,8 @@ _hb_ot_layout_skip_mark (hb_face_t    *face,
  *
  * When a ligature is formed:
  *
- *   - The ligature glyph and any marks in between all get a unique lig_id,
+ *   - The ligature glyph and any marks in between all the same newly allocated
+ *     lig_id,
  *   - The ligature glyph will get lig_comp = 0
  *   - The marks get lig_comp > 0, reflecting which component of the ligature
  *     they were applied to.
@@ -84,7 +85,7 @@ _hb_ot_layout_skip_mark (hb_face_t    *face,
  *
  *   - All resulting glyphs will have lig_id = 0,
  *   - The resulting glyphs will have lig_comp = 0, 1, 2, ... respectively.
- *   - This is used in GPOS to attack marks to the first component of a
+ *   - This is used in GPOS to attach marks to the first component of a
  *     multiple substitution in MarkBasePos.
  *
  * The numbers are also used in GPOS to do mark-to-mark positioning only
diff --git a/test/shaping/texts/in-tree/shaper-indic/south-asian/MANIFEST b/test/shaping/texts/in-tree/shaper-indic/south-asian/MANIFEST
new file mode 100644 (file)
index 0000000..3ed6c85
--- /dev/null
@@ -0,0 +1 @@
+script-tibetan
diff --git a/test/shaping/texts/in-tree/shaper-indic/south-asian/script-tibetan/MANIFEST b/test/shaping/texts/in-tree/shaper-indic/south-asian/script-tibetan/MANIFEST
new file mode 100644 (file)
index 0000000..b8752e7
--- /dev/null
@@ -0,0 +1 @@
+misc
diff --git a/test/shaping/texts/in-tree/shaper-indic/south-asian/script-tibetan/misc/MANIFEST b/test/shaping/texts/in-tree/shaper-indic/south-asian/script-tibetan/misc/MANIFEST
new file mode 100644 (file)
index 0000000..29cfb2f
--- /dev/null
@@ -0,0 +1 @@
+misc.txt
diff --git a/test/shaping/texts/in-tree/shaper-indic/south-asian/script-tibetan/misc/misc.txt b/test/shaping/texts/in-tree/shaper-indic/south-asian/script-tibetan/misc/misc.txt
new file mode 100644 (file)
index 0000000..4c9af60
--- /dev/null
@@ -0,0 +1 @@
+སྟྲཱ