Repository navigation
Rearrange morx glyphs only within a long enough marked range (#142, #143) - #433
Open
iliev-blnk wants to merge 1 commit into
Open
iliev-blnk wants to merge 1 commit into
iliev-blnk wants to merge 1 commit 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.
iliev-blnk
force-pushed
the
morx-rearrangement
branch
from
October 31, 2026 12:30
dd4a623 to
bf2861a
Compare
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.
Fixes #142, fixes #143
Cause
processIndicRearragementruns the verb of every entry on whatever rangefirstGlyph..lastGlyphholds at that moment:firstGlyphandlastGlyphare bothnull, soswap()splices at index 0 and moves glyphs from the start of the text.ABxCD => CDxABon a range of 1 to 3 glyphs.swap()then reaches past the range and movesR,YorZtoo.Fix
This follows HarfBuzz, which matches CoreText here:
Ax => xA, up to 4 forABxCD => DCxBA). Without MarkFirst, the range starts at the first glyph.endto the buffer length.ABXCD4X C D A B fourA B X C D fourA B X C D fourPQRAXYZ⓬P Q Y Z X R A one_twoP Q R A X Y Z one_twoP Q R A X Y Z one_twoPQRABCXYZ⓯P Q R C X A B Y Z one_fiveP Q R A B C X Y Z one_fiveP Q R A B C X Y Z one_fiveAcross all 174 MORT/MORX cases of text-rendering-tests, this PR goes from 93 to 131 passing: all 13 failing MORX-3 cases and all 25 MORX-5 cases. No other results change.
A rearrangement subtable with the reverse-direction flag marks its first glyph after its last one, so it now leaves the glyphs alone. Before, it spliced with a negative range length. None of the test fonts uses one. Supporting them properly, like HarfBuzz does by reversing the buffer, would be a separate change.
Tests
test/issues.js: four MORX-3 inputs and four MORX-5 inputs. Both tests fail on master.TestMORXThree.ttfandTestMORXFour.ttffrom text-rendering-tests, added totest/data/fonttest/under the Apache License 2.0 intest/data/fonttest/LICENSE.txt.npm test: 712 passing.npm run format:checkpasses.This is independent of #428, #429, #430 and #432.