diff --git a/src/OT/Layout/GPOS/MarkArray.hh b/src/OT/Layout/GPOS/MarkArray.hh index 99b442cf5..2ef81eb5e 100644 --- a/src/OT/Layout/GPOS/MarkArray.hh +++ b/src/OT/Layout/GPOS/MarkArray.hh @@ -12,7 +12,8 @@ static inline hb_position_t resolve_cross_offset (const hb_glyph_position_t *pos, unsigned int len, unsigned int glyph_pos, - hb_direction_t direction) + hb_direction_t direction, + bool reversed = false) { bool horizontal = HB_DIRECTION_IS_HORIZONTAL (direction); hb_position_t offset = horizontal ? pos[glyph_pos].y_offset : pos[glyph_pos].x_offset; @@ -25,7 +26,8 @@ resolve_cross_offset (const hb_glyph_position_t *pos, int chain = pos[glyph_pos].attach_chain(); if (!chain) break; - unsigned int parent = (int) glyph_pos + chain; + /* AAT keeps attachment chains in the original buffer order. */ + unsigned int parent = (int) glyph_pos + (reversed ? -chain : chain); if (unlikely (parent >= len)) break; glyph_pos = parent; diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index b59ff2328..e918f22d2 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -632,6 +632,13 @@ struct KerxSubTableFormat4 } break; } + hb_position_t base_offset = OT::Layout::GPOS_impl::resolve_cross_offset (buffer->pos, buffer->len, mark, + buffer->props.direction, + c->buffer_is_reversed); + if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) + o.y_offset = hb_saturate_add (o.y_offset, base_offset); + else + o.x_offset = hb_saturate_add (o.x_offset, base_offset); o.attach_type() = OT::Layout::GPOS_impl::ATTACH_TYPE_MARK; o.attach_chain() = (int) mark - (int) buffer->idx; if (c->buffer_is_reversed) diff --git a/test/shape/data/in-house/fonts/1bfb8aab9b49ef30e8deae3db271ca3dbc6208a1.ttf b/test/shape/data/in-house/fonts/1bfb8aab9b49ef30e8deae3db271ca3dbc6208a1.ttf new file mode 100644 index 000000000..47669d737 Binary files /dev/null and b/test/shape/data/in-house/fonts/1bfb8aab9b49ef30e8deae3db271ca3dbc6208a1.ttf differ diff --git a/test/shape/data/in-house/fonts/76945ad2b2303cbdf235f5be45285993eb65694b.ttf b/test/shape/data/in-house/fonts/76945ad2b2303cbdf235f5be45285993eb65694b.ttf new file mode 100644 index 000000000..a19de38a8 Binary files /dev/null and b/test/shape/data/in-house/fonts/76945ad2b2303cbdf235f5be45285993eb65694b.ttf differ diff --git a/test/shape/data/in-house/fonts/a8b4a746c2d1a1fd5d5d6108e366e79c0ae74ef5.ttf b/test/shape/data/in-house/fonts/a8b4a746c2d1a1fd5d5d6108e366e79c0ae74ef5.ttf new file mode 100644 index 000000000..e3ada0fd3 Binary files /dev/null and b/test/shape/data/in-house/fonts/a8b4a746c2d1a1fd5d5d6108e366e79c0ae74ef5.ttf differ diff --git a/test/shape/data/in-house/tests/aat-kerx.tests b/test/shape/data/in-house/tests/aat-kerx.tests index a25d41b3a..622cd13d9 100644 --- a/test/shape/data/in-house/tests/aat-kerx.tests +++ b/test/shape/data/in-house/tests/aat-kerx.tests @@ -10,3 +10,11 @@ ../fonts/9f0def61bfa49ffb44ba45c8703eee567c5bb816.ttf;;U+0045,U+0042;[E=0+600|B=1+600] ../fonts/9f0def61bfa49ffb44ba45c8703eee567c5bb816.ttf;;U+0041,U+0045;[A=0+600|E=1+600] ../fonts/9f0def61bfa49ffb44ba45c8703eee567c5bb816.ttf;--features=-kern;U+0041,U+0042;[A=0+600|B=1+600] +../fonts/76945ad2b2303cbdf235f5be45285993eb65694b.ttf;;U+0062,U+0078;[b=0+615|m=1@-440,600+150] +../fonts/76945ad2b2303cbdf235f5be45285993eb65694b.ttf;;U+0062,U+0078,U+0078;[b=0+615|m=1@-440,600+150|m=2@-590,800+150] +../fonts/a8b4a746c2d1a1fd5d5d6108e366e79c0ae74ef5.ttf;;U+0645,U+064F,U+062D,U+064E,U+0645,U+064E,U+0651,U+062F;[uni062F.fina=7+474|uni064E=4@107,-64+0|uni0651=4@109,-186+0|uni0645.medi=4+413|uni064E=2@200,-172+0|uni062D.medi=2+666|uni064F=0@143,-196+0|uni0645.init=0+456] +../fonts/a8b4a746c2d1a1fd5d5d6108e366e79c0ae74ef5.ttf;;U+0643,U+064F,U+0644,U+064F,U+0651;[uni064F=2@112,-32+0|uni0651=2@128,-154+0|uni0644.fina=2+591|uni064F=0@56,-105+0|uni0643.init=0+415] +# Cross-stream kerning followed by a backwards format 4 attachment. +# Reset c's chain so m attaches to the unshifted b. +../fonts/1bfb8aab9b49ef30e8deae3db271ca3dbc6208a1.ttf;;U+0078,U+007A,U+0062,U+0062;[m=0@925,600+150|c=1+600|b=2+615|b=3@0,100+615] +../fonts/1bfb8aab9b49ef30e8deae3db271ca3dbc6208a1.ttf;;U+0078,U+007A,U+0062,U+0062,U+0062;[m=0@925,600+150|c=1+600|b=2+615|b=3@0,100+615|b=4@0,200+615]