📜  PHP | imagickdraw getTextInterwordSpacing()函数

📅  最后修改于: 2022-05-13 01:56:53.163000             🧑  作者: Mango

PHP | imagickdraw getTextInterwordSpacing()函数

ImagickDraw::getTextInterwordSpacing()函数是PHP中的一个内置函数,用于获取文本字间距,即每个单词之间的间距。更大的数字包含更大的空间。默认间距为 0。

句法:

float ImagickDraw::getTextInterwordSpacing( void )

参数:此函数不接受任何参数。

返回值:此函数返回一个包含文本字间距的浮点值。

下面的程序说明了PHP中的ImagickDraw::getTextInterwordSpacing()函数

方案一:

getTextInterwordSpacing();
echo $textInterwordSpacing;
?>

输出:

0 // Which is the default value

方案二:

setTextInterWordSpacing(30);
  
// Get the text interword spacing
$textInterwordSpacing = $draw->getTextInterwordSpacing();
echo $textInterwordSpacing;
?>

输出:

30

方案 3:

newImage(800, 250, '#c0eb34');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Set the font size
$draw->setFontSize(20);
  
// Annotate a text
$draw->annotation(50, 80, "The text interterword spacing here is "
           . $draw->getTextInterwordSpacing());
  
// Set the text interword spacing
$draw->setTextInterwordSpacing(20);
  
// Annotate a text
$draw->annotation(50, 120, "The text interterword spacing here is "
            . $draw->getTextInterwordSpacing());
  
// Set the text interword spacing
$draw->setTextInterwordSpacing(35);
  
// Annotate a text
$draw->annotation(50, 160, "The text interterword spacing here is "
           . $draw->getTextInterwordSpacing());
  
// 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.gettextinterwordspacing。 PHP