Skip to content

Commit 86c68c7

Browse files
committed
[GPOS] Fix interaction of mark attachments and cursive chaining
Fixes #211 What happens in that bug is that a mark is attached to base first, then a second mark is cursive-chained to the first mark. This only "works" because it's in the Indic shaper where mark advances are not zeroed. Before, we didn't allow cursive to run on marks at all. Fix that. We also where updating mark major offsets at the end of GPOS, such that changes in advance of base will not change the mark attachment position. That was superior to the alternative (which is what Uniscribe does BTW), but made it hard to apply cursive to the mark after it was positioned. We could track major-direction offset changes and apply that to cursive in the post process, but that's a much trickier thing to do than the fix here, which is to immediately apply the major-direction advance-width offsets... Ie.: #211 (comment) If this breaks any fonts, the font should be fixed to do mark attachment after all the advances are set up first (kerning, etc). Finally, this, still doesn't make us match Uniscribe, for I explained in that bug. Looks like Uniscribe applies minor-direction cursive adjustment immediate as well. We don't, and we like it our way, at least for now. Eg. the sequence in the test case does this: - The first subscript attaches with mark-to-base, moving in x only, - The second subscript attaches with cursive attachment to first subscript moving in x only, - A final context rule moves the first subscript up by 104 units. The way we do, the final shift-up, also shifts up the second subscript mark because it's cursively-attached. Uniscribe doesn't. We get: [ttaorya=0+1307|casubscriptorya=0@-242,104+-231|casubscriptnarroworya=0@20,104+507] while Uniscribe gets: [ttaorya=0+1307|casubscriptorya=0@-242,104+-211|casubscriptnarroworya=0+487] note the different y-offset of the last glyph. In our view, after cursive, things move together, period.
1 parent 80c8855 commit 86c68c7

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

src/hb-ot-layout-gpos-table.hh

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,22 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
437437
o.attach_type() = ATTACH_TYPE_MARK;
438438
o.attach_chain() = (int) glyph_pos - (int) buffer->idx;
439439
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
440+
{
441+
unsigned int i = buffer->idx;
442+
unsigned int j = glyph_pos;
443+
hb_glyph_position_t *pos = buffer->pos;
444+
assert (j < i);
445+
if (HB_DIRECTION_IS_FORWARD (c->direction))
446+
for (unsigned int k = j; k < i; k++) {
447+
pos[i].x_offset -= pos[k].x_advance;
448+
pos[i].y_offset -= pos[k].y_advance;
449+
}
450+
else
451+
for (unsigned int k = j + 1; k < i + 1; k++) {
452+
pos[i].x_offset += pos[k].x_advance;
453+
pos[i].y_offset += pos[k].y_advance;
454+
}
455+
}
440456

441457
buffer->idx++;
442458
return_trace (true);
@@ -917,9 +933,6 @@ struct CursivePosFormat1
917933
TRACE_APPLY (this);
918934
hb_buffer_t *buffer = c->buffer;
919935

920-
/* We don't handle mark glyphs here. */
921-
if (unlikely (_hb_glyph_info_is_mark (&buffer->cur()))) return_trace (false);
922-
923936
const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)];
924937
if (!this_record.exitAnchor) return_trace (false);
925938

@@ -1580,18 +1593,6 @@ propagate_attachment_offsets (hb_glyph_position_t *pos, unsigned int i, hb_direc
15801593
{
15811594
pos[i].x_offset += pos[j].x_offset;
15821595
pos[i].y_offset += pos[j].y_offset;
1583-
1584-
assert (j < i);
1585-
if (HB_DIRECTION_IS_FORWARD (direction))
1586-
for (unsigned int k = j; k < i; k++) {
1587-
pos[i].x_offset -= pos[k].x_advance;
1588-
pos[i].y_offset -= pos[k].y_advance;
1589-
}
1590-
else
1591-
for (unsigned int k = j + 1; k < i + 1; k++) {
1592-
pos[i].x_offset += pos[k].x_advance;
1593-
pos[i].y_offset += pos[k].y_advance;
1594-
}
15951596
}
15961597
}
15971598

Binary file not shown.

test/shaping/fonts/sha1sum/MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
5a5daf5eb5a4db77a2baa3ad9c7a6ed6e0655fa8.ttf
2323
641bd9db850193064d17575053ae2bf8ec149ddc.ttf
2424
6466d38c62e73a39202435a4f73bf5d6acbb73c0.ttf
25+
706c5d7b625f207bc0d874c67237aad6f1e9cd6f.ttf
2526
757ebd573617a24aa9dfbf0b885c54875c6fe06b.ttf
2627
7a37dc4d5bf018456aea291cee06daf004c0221c.ttf
2728
7e14e7883ed152baa158b80e207b66114c823a8b.ttf
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
fonts/sha1sum/c4e48b0886ef460f532fb49f00047ec92c432ec0.ttf::U+0643,U+0645,U+0645,U+062B,U+0644:[gid8=4+738|gid5=3@441,1197+0|gid6=3@0,432+405|gid9=2@0,477+452|gid9=1@0,977+452|gid10=0@20,1577+207]
22
fonts/sha1sum/298c9e1d955f10f6f72c6915c3c6ff9bf9695cec.ttf::U+0643,U+0645,U+0645,U+062B,U+0644:[gid8=4+738|gid5=3@441,1197+0|gid6=3@0,432+405|gid9=2@0,477+500|gid9=1@0,577+452|gid10=0@20,1177+207]
3+
fonts/sha1sum/706c5d7b625f207bc0d874c67237aad6f1e9cd6f.ttf::U+0B1F,U+0B4D,U+0B1A,U+0B4D,U+0B1A:[ttaorya=0+1307|casubscriptorya=0@-242,104+-231|casubscriptnarroworya=0@20,104+507]

0 commit comments

Comments
 (0)