From 7e42d03a24d7ff74eceb4b7a8fd200537e5e61d7 Mon Sep 17 00:00:00 2001 From: jygaulier Date: Wed, 3 Jan 2024 18:51:05 +0100 Subject: [PATCH] PHRAS-3987: fix do not add text shadow if no shadow attribute (#4454) --- lib/classes/recordutils/image.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/classes/recordutils/image.php b/lib/classes/recordutils/image.php index 718c782baf..45d74ce34c 100644 --- a/lib/classes/recordutils/image.php +++ b/lib/classes/recordutils/image.php @@ -289,11 +289,19 @@ class recordutils_image $txtline = $texts->item($i)->nodeValue; if ($txtline != '') { - $wrap = static::wrap($imagine, $fontsize, 0, __DIR__ . '/../../../resources/Fonts/arial.ttf', $txtline, $text_width); + $shadow = $texts->item($i)->getAttribute('shadow'); + if($shadow) { + $shadowColor = $xmlToColor($shadow, [0, 0, 0, 127]); + $wrap = static::wrap($imagine, $fontsize, 0, __DIR__ . '/../../../resources/Fonts/arial.ttf', $txtline, $text_width, true); + } + else { + $shadowColor = null; + $wrap = static::wrap($imagine, $fontsize, 0, __DIR__ . '/../../../resources/Fonts/arial.ttf', $txtline, $text_width, false); + } $txtblock[] = [ 'fontsize' => $fontsize, 'fontcolor' => $xmlToColor($texts->item($i)->getAttribute('color'), [0, 0, 0]), - 'shadowcolor' => $xmlToColor($texts->item($i)->getAttribute('shadow'), [0, 0, 0, 127]), + 'shadowcolor' => $shadowColor, 'h' => $wrap['toth'], 'lines' => $wrap['l'], ]; @@ -541,9 +549,10 @@ class recordutils_image * @param string $fontFace * @param string $string * @param int $width + * @param bool $withShadow * @return array */ - protected static function wrap(ImagineInterface $imagine, $fontSize, $angle, $fontFace, $string, $width) + protected static function wrap(ImagineInterface $imagine, $fontSize, $angle, $fontFace, $string, $width, $withShadow) { static $palette;