1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-09 15:26:38 +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;
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;
}

View File

@@ -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