Repository navigation
Insert glyphs at the end of the text in morx insertion subtables - #436
Open
iliev-blnk wants to merge 3 commits into
Open
iliev-blnk wants to merge 3 commits into
iliev-blnk wants to merge 3 commits into
Conversation
…#142, foliojs#143) Skip a rearrangement verb when nothing has been marked yet or when the marked range is shorter than the glyphs the verb moves, like CoreText and HarfBuzz. Clamp the end of the range at the end of the text.
Like HarfBuzz, insertion subtables processed in forward order now take the end-of-text transition: a current insertion goes at the end of the glyphs and a marked insertion at the mark. The state machine takes the index the processor returns there, and stops unless it points at inserted glyphs the machine doesn't skip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #434. Its end-of-text transition still skipped glyph insertion subtables, while HarfBuzz inserts glyphs there.
Cause
processGlyphInsertionreturns early when there is no current glyph, so a font's insertions in its end-of-text transitions are dropped. And the state machine ignored the index a processor returns at the end of the text, so once glyphs were inserted there, it would go on to the second inserted glyph instead of stopping or, with DontAdvance, processing the first one.None of the text-rendering-tests fonts insert glyphs at the end of the text, so I built a test font from MORX-32 with fontTools. Only its end-of-text transitions insert glyphs:
A: current insertion ofI N S, which goes at the end of the textB(with SetMark): marked insertion ofI N Safter theBC: current insertion ofBwith DontAdvance, so the insertedBis processed too and gets its ownI N SFix
AAA I N SA I N SAYYA Y YA Y Y I N SA Y Y I N SBYYB Y YB I N S Y YB I N S Y YCCC B I N SC B I N SACA CA C B I N SA C B I N SAX,BX(no insertion)Across all 174 MORT/MORX cases of text-rendering-tests, nothing changes (165 passing on top of #434).
Not covered: subtables processed in reverse order still skip insertion at the end of the text. Their insertion already differs from HarfBuzz in the middle of the text (HarfBuzz inserts the glyphs on the other side and in reverse order), so I'd rather fix both together in a separate change.
This builds on #434, which builds on #433. Only the last commit is new here.
Tests
test/shaping.js: seven inputs for the new font. The five that insert glyphs fail without the fix, andCandACalso fail with only the insertion change, without the state machine one.test/data/fonttest/TestMORXEndOfTextInsertion.ttfis MORX-32 from text-rendering-tests with its insertion subtable rebuilt, so it is under the Apache License 2.0 intest/data/fonttest/LICENSE.txt.npm test: 750 passing.npm run format:checkpasses.