diff --git a/src/Mpdf.php b/src/Mpdf.php index 523b8b7d6..058ec598d 100644 --- a/src/Mpdf.php +++ b/src/Mpdf.php @@ -18830,9 +18830,10 @@ function setCSS($arrayaux, $type = '', $tag = '') case 'FONT-VARIANT-POSITION': - if (isset($this->OTLtags['Plus'])) { - $this->OTLtags['Plus'] = str_replace(['sups', 'subs'], '', $this->OTLtags['Plus']); + if (!isset($this->OTLtags['Plus'])) { + $this->OTLtags['Plus'] = ''; } + $this->OTLtags['Plus'] = str_replace(['sups', 'subs'], '', $this->OTLtags['Plus']); switch (strtoupper($v)) { case 'SUPER': $this->OTLtags['Plus'] .= ' sups'; diff --git a/tests/Mpdf/FontVariantPositionTest.php b/tests/Mpdf/FontVariantPositionTest.php new file mode 100644 index 000000000..9377f54e4 --- /dev/null +++ b/tests/Mpdf/FontVariantPositionTest.php @@ -0,0 +1,38 @@ + 'freeserif']); + $mpdf->compress = false; + + $mpdf->WriteHTML( + '1' + . '1' + . '1' + ); + + $output = $mpdf->OutputBinaryData(); + $mpdf->cleanup(); + + preg_match_all('/<([0-9a-fA-F]+)>\s*Tj/', $output, $matches); + + $this->assertCount(3, $matches[1], 'Expected one text-showing operator per span'); + + list($super, $sub, $normal) = $matches[1]; + + $this->assertSame('31', $normal, 'font-variant-position: normal must leave the digit alone'); + $this->assertNotSame($normal, $super, 'font-variant-position: super must substitute the glyph'); + $this->assertNotSame($normal, $sub, 'font-variant-position: sub must substitute the glyph'); + $this->assertNotSame($super, $sub, 'sups and subs must not resolve to the same glyph'); + } + +}