diff --git a/CHANGELOG-GRAVITYPDF.md b/CHANGELOG-GRAVITYPDF.md index bbfff2e9f..d4b40a2a9 100644 --- a/CHANGELOG-GRAVITYPDF.md +++ b/CHANGELOG-GRAVITYPDF.md @@ -273,6 +273,7 @@ Bugfixes * Arabic in an SVG was not given an Arabic font. [#281] * An RGB image converted to CMYK truncated its inks, so full ink fell short of 255. [#349] [#354] * An image's `/SMask` pointed at whichever object came before it, which is only its mask if nothing was added in between. An image and its soft mask are now registered together. [#373] +* A `` with no `font-size` from its tag or the CSS raised three `Undefined array key "fontsize"` warnings. It is now drawn at the size of the text around it, as though that size were set on it. [#645] [#678] ### Forms @@ -935,3 +936,5 @@ These changes do not change output. [#543]: https://github.com/GravityPDF/mpdf/issues/543 [#656]: https://github.com/GravityPDF/mpdf/pull/656 [#654]: https://github.com/GravityPDF/mpdf/pull/654 +[#645]: https://github.com/GravityPDF/mpdf/issues/645 +[#678]: https://github.com/GravityPDF/mpdf/pull/678 diff --git a/src/Tag/TextCircle.php b/src/Tag/TextCircle.php index 6e5652f57..bcef38d5a 100644 --- a/src/Tag/TextCircle.php +++ b/src/Tag/TextCircle.php @@ -74,6 +74,7 @@ public function open($attr, &$ahtml, &$ihtml) $objattr['visibility'] = $v; } } + $objattr['fontsize'] = $this->mpdf->FontSizePt; if (isset($properties['FONT-SIZE'])) { if (strtolower($properties['FONT-SIZE']) === 'auto') { if ($objattr['top-text'] && $objattr['bottom-text']) { diff --git a/tests/Mpdf/TextCircleFontSizeTest.php b/tests/Mpdf/TextCircleFontSizeTest.php new file mode 100644 index 000000000..4d0770a7c --- /dev/null +++ b/tests/Mpdf/TextCircleFontSizeTest.php @@ -0,0 +1,66 @@ +drawnPages($mode, $html, ''); + $this->assertStringContainsString(' ' . $size . ' Tf', $pages[0]); + $this->assertSame($this->drawnPages($mode, $html, ' style="font-size: ' . $size . 'pt"'), $pages); + } + + /** + * Draw the document, asserting it raises nothing, and hand back its page content streams + * + * @param string $mode A CssMode constant + * @param string $html The document, with {style} where the text circle's style attribute goes + * @param string $style What goes in place of {style} + * + * @return string[] + */ + private function drawnPages($mode, $html, $style) + { + $pdf = $this->assertDrawsSilently(function (Mpdf $mpdf) use ($html, $style) { + $mpdf->WriteHTML(str_replace('{style}', $style, $html)); + }, ['cssMode' => $mode]); + + return $this->pages($pdf); + } + + /** + * @return array[] Each CSS mode with a text circle at the top of the document, in a paragraph and in a table cell + */ + public function providerContexts() + { + $contexts = [ + 'document' => ['', '11.000'], + 'paragraph' => ['

', '14.000'], + 'table cell' => ['
', '9.000'], + ]; + + $cases = []; + foreach ([CssMode::STANDARD, CssMode::LEGACY] as $mode) { + foreach ($contexts as $name => $context) { + $cases[$mode . ', ' . $name] = array_merge([$mode], $context); + } + } + + return $cases; + } +}