1
0
mirror of https://github.com/Intervention/image.git synced 2025-03-15 22:49:40 +01:00

Change box size calculation for Imagick font

This commit is contained in:
Oliver Vogel 2022-07-05 14:53:30 +02:00
parent bb6d81b96f
commit 58d17f044f
3 changed files with 21 additions and 21 deletions

View File

@ -27,6 +27,11 @@ class TextWriter extends AbstractTextWriter
$line
);
}
// debug
// $lines = new TextBlock($this->text);
// $box = $lines->getBoundingBox($this->font, $this->position);
// imagepolygon($frame->getCore(), $box->toArray(), 0);
} else {
foreach ($lines as $line) {
imagestring(

View File

@ -59,7 +59,7 @@ class Font extends AbstractFont
return (new Size(
intval(round($dimensions['textWidth'])),
intval(round($dimensions['textHeight'])),
intval(round($dimensions['ascender'] + $dimensions['descender'])),
))->toPolygon();
}
}

View File

@ -23,31 +23,26 @@ class TextWriter extends AbstractTextWriter
$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;
}
// 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
{
if (!is_a($this->font, Font::class)) {