1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-11 08:24:02 +02:00
This commit is contained in:
Oliver Vogel
2023-10-22 16:00:33 +02:00
parent 27f8778187
commit 2754da5e6f
2 changed files with 8 additions and 5 deletions

View File

@@ -15,22 +15,25 @@ class Font extends AbstractFont
{ {
use CanHandleColors; use CanHandleColors;
public function toImagickDraw(ColorspaceInterface $colorspace): ImagickDraw public function toImagickDraw(?ColorspaceInterface $colorspace = null): ImagickDraw
{ {
if (!$this->hasFilename()) { if (!$this->hasFilename()) {
throw new FontException('No font file specified.'); throw new FontException('No font file specified.');
} }
$color = $this->colorToPixel($this->getColor(), $colorspace);
$draw = new ImagickDraw(); $draw = new ImagickDraw();
$draw->setStrokeAntialias(true); $draw->setStrokeAntialias(true);
$draw->setTextAntialias(true); $draw->setTextAntialias(true);
$draw->setFont($this->getFilename()); $draw->setFont($this->getFilename());
$draw->setFontSize($this->getSize()); $draw->setFontSize($this->getSize());
$draw->setFillColor($color);
$draw->setTextAlignment(Imagick::ALIGN_LEFT); $draw->setTextAlignment(Imagick::ALIGN_LEFT);
if ($colorspace) {
$draw->setFillColor(
$this->colorToPixel($this->getColor(), $colorspace)
);
}
return $draw; return $draw;
} }

View File

@@ -54,7 +54,7 @@ trait CanHandleColors
* the image colorspace which is passed to this method. * the image colorspace which is passed to this method.
* *
* @param ColorInterface $color * @param ColorInterface $color
* @param ColorspceInterface $colorspace * @param ColorspaceInterface $colorspace
* @return ImagickPixel * @return ImagickPixel
*/ */
public function colorToPixel(ColorInterface $color, ColorspaceInterface $colorspace): ImagickPixel public function colorToPixel(ColorInterface $color, ColorspaceInterface $colorspace): ImagickPixel