diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index a2ea946524..8f9d2f35be 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -702,6 +702,13 @@ protected static function parseStyle($attribute, $styles) } $styles['italic'] = $tValue; break; + case 'font-variant': + $tValue = false; + if (preg_match('#small-caps#', $cValue)) { + $tValue = true; + } + $styles['smallCaps'] = $tValue; + break; case 'margin': $cValue = Converter::cssToTwip($cValue); $styles['spaceBefore'] = $cValue; diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php index 80f96d5773..521d37d58c 100644 --- a/tests/PhpWord/Shared/HtmlTest.php +++ b/tests/PhpWord/Shared/HtmlTest.php @@ -132,6 +132,21 @@ public function testParseTextDecoration() $this->assertEquals('single', $doc->getElementAttribute('/w:document/w:body/w:p/w:r/w:rPr/w:u', 'w:val')); } + /** + * Test font-variant style + */ + public function testParseFontVariant(): void + { + $html = 'test'; + $phpWord = new \PhpOffice\PhpWord\PhpWord(); + $section = $phpWord->addSection(); + Html::addHtml($section, $html); + + $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007'); + $this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:rPr/w:smallCaps')); + $this->assertEquals('1', $doc->getElementAttribute('/w:document/w:body/w:p/w:r/w:rPr/w:smallCaps', 'w:val')); + } + /** * Test font */