PHP | imagickdraw getTextInterlineSpacing()函数
ImagickDraw::getTextInterlineSpacing()函数是PHP中的一个内置函数,用于获取文本行间距。数字越大,空间越大。默认间距为 0。
句法:
float ImagickDraw::getTextInterlineSpacing( void )
参数:此函数不接受任何参数。
返回值:此函数返回一个包含文本行间距的浮点值。
异常:此函数在出错时抛出 ImagickException。
下面的程序说明了PHP中的ImagickDraw::getTextInterlineSpacing()函数:
方案一:
getTextInterLineSpacing();
echo $textInterlineSpacing;
?>
输出:
0 // Which is the default value
方案二:
setTextInterLineSpacing(50);
// Get the text interline spacing
$textInterlineSpacing = $draw->getTextInterLineSpacing();
echo $textInterlineSpacing;
?>
输出:
50
方案 3:
newImage(800, 250, 'brown');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the fill color
$draw->setFillColor('white');
// Set the font size
$draw->setFontSize(20);
// Annotate a text
$draw->annotation(50, 100, "The text interterline \nspacing here is "
. $draw->getTextInterLineSpacing());
// Set the text interline spacing
$draw->setTextInterLineSpacing(30);
// Annotate a text
$draw->annotation(300, 100, "The text interterline \nspacing here is "
. $draw->getTextInterLineSpacing());
// Set the text interline spacing
$draw->setTextInterLineSpacing(50);
// Annotate a text
$draw->annotation(550, 100, "The text interterline \nspacing here is "
. $draw->getTextInterLineSpacing());
// Render the draw commands
$imagick->drawImage($draw);
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>
输出:
参考: https://www. PHP.net/manual/en/imagickdraw.gettextinterlinespacing。 PHP