summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2015-08-25 18:55:34 +0100
committerBehdad Esfahbod <behdad@behdad.org>2015-08-25 18:58:24 +0100
commit58f2a73fb95af42e264a91cdef7bb5a89e965601 (patch)
tree9b23837f5bc93c2dbfdc9ee30cc019100e87f804
parentfdd1770e006ca2d2973c049177ceda87a575e07f (diff)
downloadharfbuzz-58f2a73fb95af42e264a91cdef7bb5a89e965601.tar.gz
[GPOS] Rewrite cursive attachment slightly differently
In anticipation for upcoming fix for bug reported by Khaled in thread "Issue with cursive attachment".
-rw-r--r--src/hb-ot-layout-gpos-table.hh36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index da9506c7..6dcada6d 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -960,20 +960,32 @@ struct CursivePosFormat1
}
/* Cross-direction adjustment */
- if (c->lookup_props & LookupFlag::RightToLeft) {
- pos[i].cursive_chain() = j - i;
- if (likely (HB_DIRECTION_IS_HORIZONTAL (c->direction)))
- pos[i].y_offset = entry_y - exit_y;
- else
- pos[i].x_offset = entry_x - exit_x;
- } else {
- pos[j].cursive_chain() = i - j;
- if (likely (HB_DIRECTION_IS_HORIZONTAL (c->direction)))
- pos[j].y_offset = exit_y - entry_y;
- else
- pos[j].x_offset = exit_x - entry_x;
+
+ /* We attach child to parent (think graph theory and rooted trees whereas
+ * the root stays on baseline and each node aligns itself against its
+ * parent.
+ *
+ * Optimize things for the case of RightToLeft, as that's most common in
+ * Arabinc. */
+ unsigned int child = i;
+ unsigned int parent = j;
+ hb_position_t x_offset = entry_x - exit_x;
+ hb_position_t y_offset = entry_y - exit_y;
+ if (!(c->lookup_props & LookupFlag::RightToLeft))
+ {
+ unsigned int k = child;
+ child = parent;
+ parent = k;
+ x_offset = -x_offset;
+ y_offset = -y_offset;
}
+ pos[child].cursive_chain() = parent - child;
+ if (likely (HB_DIRECTION_IS_HORIZONTAL (c->direction)))
+ pos[child].y_offset = y_offset;
+ else
+ pos[child].x_offset = x_offset;
+
buffer->idx = j;
return TRACE_RETURN (true);
}