Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Mpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
38 changes: 38 additions & 0 deletions tests/Mpdf/FontVariantPositionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Mpdf;

class FontVariantPositionTest extends \Yoast\PHPUnitPolyfills\TestCases\TestCase
{

/**
* FreeSerif carries the sups and subs GSUB features, so each keyword has to reach the text
* as a different glyph. Rendered in one document the subset ids are comparable.
*/
public function testKeywordsSelectDistinctGlyphs()
{
$mpdf = new Mpdf(['default_font' => 'freeserif']);
$mpdf->compress = false;

$mpdf->WriteHTML(
'<span style="font-variant-position: super">1</span>'
. '<span style="font-variant-position: sub">1</span>'
. '<span style="font-variant-position: normal">1</span>'
);

$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');
}

}
Loading