问题:如果行大小超过100px,我该如何转移字母?同时保留字母间距?
我不知道怎么做,如果行宽$ width提议不适合,那么它应该带一个保持字母间距的新行。请告诉我
我的代码字母间距:
$width = 100; //max 100px in line
$_letter_int = 10; // size letter spacing 10px
$body = 'My name is IxtWall noobs';
$canvas = new Imagick();
$draw = new ImagickDraw();
$color = new ImagickPixel('#00000');
$draw->setFont('Arial.ttf');
$draw->setFontSize(23);
$draw->setFillColor($color);
$draw->setTextAntialias(true);
$left_int = 0;
$global_data = $canvas->queryFontMetrics($draw, $body);
$height = $global_data['textHeight'];
foreach( str_split($body) as $val )
{
$data = $canvas->queryFontMetrics($draw, $val);
$draw->annotation($left_int, $global_data['ascender'], $val);
$left_int += $_letter_int + round($data['boundingBox']['x2']);
}
$canvas->newImage($width, $height, 'none');
$canvas->drawImage($draw);
$canvas->setImageFormat('png');
header('Content-Type: image/png');
echo $canvas->getImageBlob();