Repository navigation
Swap a Sinhala al-lakuna against a Consonant + Halant post-base Lookup as the other viramas are (#435) - #501
Merged
Conversation
…p as the other viramas are The old-spec compatibility swap in Otl recognised a virama from a hard-coded string that stopped at Malayalam, while the parser read Sinhala's U+0DCA from its own list. The list now lives on Shaper\Indic and both read it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
The old-spec compatibility swap (
_OTL_OLD_SPEC_COMPAT_1) inOtl::applyGSUBlookupOverRun()identified a virama by searching a hard-coded string that covered Devanagari to Malayalam only. The parser already reads the Sinhala al-lakuna, U+0DCA, fromTTFontFile::$viramas. As a result, a Sinhala font whosepref,blwforpstfligature is written Consonant + Halant had the consonant's class read by the parser, but the shaper never formed the ligature.Fix
The list moves to
Mpdf\Shaper\Indic::$viramas, and the parser (TTFontFile::indicConsonant()) and the swap inOtlnow both read it. The hard-coded string is gone. A test checks that the list matches the virama column ofIndic::$indic_configsfrom Devanagari to Sinhala. Khmer's coeng and Javanese's pangkon are left out deliberately, because neither script's classes are read this way.Test and fixture
tests/data/ttf/NotoSansSinhala-OldOrderBlwf-Synthetic.ttf(6,416 bytes) was built with fontTools 4.59.2 in the same way as the #331 and #385 fixtures. It keeps the glyphs, cmap and GDEF ofNotoSansSinhala-Subset.ttf, drops GPOS, and has a GSUB written by hand. That GSUB has one feature,blwfundersinh, with one ligature in the old order:uni0DBB uni0DCA -> glyph00022. A sibling font with the same ligature in the new order (uni0DCA uni0DBB) was built for comparison and is not committed.tests/Mpdf/SinhalaOldOrderPostBaseFormTest.php:gravitypdfhb-shape14.3.1, new-order fontThe first three fail on
gravitypdf. HarfBuzz does not swap, so on the old-order font it draws all four runs unchanged.The swap only reaches Sinhala when AL-LAKUNA comes directly before the consonant. mPDF's Sinhala syllable grammar joins consonants only through AL-LAKUNA + ZWJ or ZWJ + AL-LAKUNA. So the ZWJ + AL-LAKUNA order is the one where the Halant is followed directly by a consonant after the base.
The font also joins the four golden-master corpora (fontcache, otldump, shaping, subset). No existing fixture or snapshot changed.
Font survey
Every font in
packages/,tests/data/ttf,/System/Library/Fonts,/Library/Fontsand~/Library/Fontswith asinhGSUB script and a U+0DCA glyph (fontTools, counting two-glyph Type 4 ligatures with AL-LAKUNA underpref/blwf/pstf):sinh)pstf(Type 1 single substitutions on split vowel signs)vatu)vatu,psts)vatu,psts)blwfI shaped 7,954 generated runs through mPDF in each of these nine fonts before and after the change. The runs were C+H+C, C+H+ZWJ+C and C+ZWJ+H+C for every pair of consonants, repaya + ZWJ-joined conjuncts, and C+H(+ZWJ)+YA/RA with five vowel signs.
hb-shapeon the new-order sibling. All 24 of those that change now match it, and none of them matched before. In total, 157 of the 180 match after the change, against 133 before.So no bundled or system Sinhala font is affected. The change is still worth making because it keeps the parser and the shaper from reading different virama sets.
Gates
composer test: 4,078 tests, 5 skipped. The skips are outside this change.composer cs: clean.Upstream
mpdf/mpdfdevelopmenthas the same hard-coded string in this branch, so this should be mirrored upstream. That PR will need a changelog entry.Fixes #435
🤖 Generated with Claude Code