mpdf
mpdf copied to clipboard
Initialize Plus tag if not set in FONT-VARIANT-POSITION
Description
This pull request ensures that the $this->OTLtags['Plus'] index is always initialized before being used in the FONT-VARIANT-POSITION case.
Previously, if the Plus index was not set, PHP would throw an "Undefined index: Plus" error.
With this change, the code checks whether $this->OTLtags['Plus'] is set.
If not, it initializes it as an empty string before any manipulation.
This prevents runtime errors and improves reliability when processing font variant positions.
Motivation and Rationale
- Avoid PHP notices and potential fatal errors when the
Pluskey is not initialized. - Multiple code paths can reach this logic without guaranteeing that
$this->OTLtags['Plus']exists, especially when handling new or edge-case font variants. - This fix makes the code more robust and easier to maintain.
Impact
- Prevents “Undefined index: Plus” errors.
- Improves stability when handling font-position variants.
- No impact on other functionality or tags.
Testing
- Verified that the error no longer occurs in scenarios where FONT-VARIANT-POSITION is set without prior initialization of
$this->OTLtags['Plus']. - All existing and new unit tests for font-variant processing pass successfully.
Changelog
- Added: Always initialize
$this->OTLtags['Plus']before use in FONT-VARIANT-POSITION to prevent undefined index errors.
Thank you for the PR. Please provide a unit test representing the undefined index error without this code change.