From 2754da5e6f43e9089ad20f59e55b3eef3617f28c Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 22 Oct 2023 16:00:33 +0200 Subject: [PATCH] Fix bugs --- src/Drivers/Imagick/Font.php | 11 +++++++---- src/Drivers/Imagick/Traits/CanHandleColors.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Drivers/Imagick/Font.php b/src/Drivers/Imagick/Font.php index abea0185..a7d7c2e4 100644 --- a/src/Drivers/Imagick/Font.php +++ b/src/Drivers/Imagick/Font.php @@ -15,22 +15,25 @@ class Font extends AbstractFont { use CanHandleColors; - public function toImagickDraw(ColorspaceInterface $colorspace): ImagickDraw + public function toImagickDraw(?ColorspaceInterface $colorspace = null): ImagickDraw { if (!$this->hasFilename()) { throw new FontException('No font file specified.'); } - $color = $this->colorToPixel($this->getColor(), $colorspace); - $draw = new ImagickDraw(); $draw->setStrokeAntialias(true); $draw->setTextAntialias(true); $draw->setFont($this->getFilename()); $draw->setFontSize($this->getSize()); - $draw->setFillColor($color); $draw->setTextAlignment(Imagick::ALIGN_LEFT); + if ($colorspace) { + $draw->setFillColor( + $this->colorToPixel($this->getColor(), $colorspace) + ); + } + return $draw; } diff --git a/src/Drivers/Imagick/Traits/CanHandleColors.php b/src/Drivers/Imagick/Traits/CanHandleColors.php index 96017ced..c1a583f1 100644 --- a/src/Drivers/Imagick/Traits/CanHandleColors.php +++ b/src/Drivers/Imagick/Traits/CanHandleColors.php @@ -54,7 +54,7 @@ trait CanHandleColors * the image colorspace which is passed to this method. * * @param ColorInterface $color - * @param ColorspceInterface $colorspace + * @param ColorspaceInterface $colorspace * @return ImagickPixel */ public function colorToPixel(ColorInterface $color, ColorspaceInterface $colorspace): ImagickPixel