Initialise the OTL Plus tag before font-variant-position appends to it (mirrors mpdf/mpdf#2136) - #16
Merged
Conversation
setCSS() clears OTLtags to [] between elements, so the first font-variant-position: super or sub in a document appends to an unset key: "Undefined array key" on PHP 8, "Undefined index" before that. Every sibling case — FONT-VARIANT-CAPS, -LIGATURES, -NUMERIC and -ALTERNATES — already opens by defaulting Plus to an empty string; FONT-VARIANT-POSITION guarded the str_replace() instead, which leaves the append below it unprotected. Use the same shape as its siblings. Mirrors mpdf#2136. Co-Authored-By: Claude Opus 5 <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.
Summary
This mirrors mpdf#2136, so the fork carries the fix while the upstream PR sits open.
setCSS()clears$this->OTLtagsto[]between elements. TheFONT-VARIANT-POSITIONcase then does$this->OTLtags['Plus'] .= ' sups'— appending to a key that is not there. It guards thestr_replace()above it withisset()but leaves the append unguarded, so the firstfont-variant-position: superorsubin a document raises Undefined array key "Plus" on PHP 8, Undefined index: Plus before that.Its four siblings —
FONT-VARIANT-CAPS,-LIGATURES,-NUMERICand-ALTERNATES— all open by defaultingPlusto an empty string. This case now does the same, so thestr_replace()no longer needs a guard of its own.Try it
On
gravitypdf, withdisplay_errorson:On this branch, nothing.
Test plan
composer test— 1049 tests, 2535 assertions, green (gravitypdfis at 1048).composer cs— clean.gravitypdf, none new.tests/Mpdf/FontVariantPositionTest.phpfails ongravitypdfand passes here.More info
Where it differs from upstream
ifafter the existingisset()block, indented with spaces in a tab-indented file (composer csrejects it)isset()into the!isset()default its siblings use, so there is one guard rather than twoThe test
Asserting "no warning" alone would pass against a fix that broke the feature, so the test checks that the keywords still reach the OTL layer. FreeSerif carries both the
supsandsubsGSUB features, and rendering all three keywords in one document makes the subset glyph ids comparable:comes out as three different glyphs, with the last one the plain digit. That covers the whole case in one pass: the append for
super, thestr_replace()forsubclearing the previoussups, andnormalclearing both.mpdf/font-bundle-allis a dev dependency, so FreeSerif is present in CI.