mirror of
https://github.com/Intervention/image.git
synced 2025-08-20 12:41:23 +02:00
Change box size calculation for Imagick font
This commit is contained in:
@@ -27,6 +27,11 @@ class TextWriter extends AbstractTextWriter
|
|||||||
$line
|
$line
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// debug
|
||||||
|
// $lines = new TextBlock($this->text);
|
||||||
|
// $box = $lines->getBoundingBox($this->font, $this->position);
|
||||||
|
// imagepolygon($frame->getCore(), $box->toArray(), 0);
|
||||||
} else {
|
} else {
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
imagestring(
|
imagestring(
|
||||||
|
@@ -59,7 +59,7 @@ class Font extends AbstractFont
|
|||||||
|
|
||||||
return (new Size(
|
return (new Size(
|
||||||
intval(round($dimensions['textWidth'])),
|
intval(round($dimensions['textWidth'])),
|
||||||
intval(round($dimensions['textHeight'])),
|
intval(round($dimensions['ascender'] + $dimensions['descender'])),
|
||||||
))->toPolygon();
|
))->toPolygon();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,31 +23,26 @@ class TextWriter extends AbstractTextWriter
|
|||||||
$line
|
$line
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// debug
|
||||||
|
// $lines = new TextBlock($this->text);
|
||||||
|
// $box = $lines->getBoundingBox($this->font, $this->position);
|
||||||
|
// $points = [];
|
||||||
|
// foreach (array_chunk($box->toArray(), 2) as $p) {
|
||||||
|
// $points[] = ['x' => $p[0], 'y' => $p[1]];
|
||||||
|
// }
|
||||||
|
// $draw = new \ImagickDraw();
|
||||||
|
// $draw->setStrokeOpacity(1);
|
||||||
|
// $draw->setStrokeColor('black');
|
||||||
|
// $draw->setFillColor('transparent');
|
||||||
|
// $draw->polygon($points);
|
||||||
|
// $frame->getCore()->drawImage($draw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $image;
|
return $image;
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected function getAlignedPosition(): Point
|
|
||||||
// {
|
|
||||||
// $position = $this->position;
|
|
||||||
// $box = $this->getFont()->getBoxSize($this->text);
|
|
||||||
//
|
|
||||||
// // adjust y pos
|
|
||||||
// switch ($this->getFont()->getValign()) {
|
|
||||||
// case 'top':
|
|
||||||
// $position->setY($position->getY() + $box->height());
|
|
||||||
// break;
|
|
||||||
//
|
|
||||||
// case 'middle':
|
|
||||||
// case 'center':
|
|
||||||
// $position->setY(intval($position->getY() + round($box->height() / 2)));
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return $position;
|
|
||||||
// }
|
|
||||||
|
|
||||||
protected function getFont(): FontInterface
|
protected function getFont(): FontInterface
|
||||||
{
|
{
|
||||||
if (!is_a($this->font, Font::class)) {
|
if (!is_a($this->font, Font::class)) {
|
||||||
|
Reference in New Issue
Block a user