当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


PHP ImagickDraw getTextInterwordSpacing()用法及代码示例


ImagickDraw::getTextInterwordSpacing()函数是PHP中的内置函数,用于获取文本inter-word间距,该间距表示每个单词之间的间距。数字越大,包含的空间越大。默认间距为0。

用法:

float ImagickDraw::getTextInterwordSpacing( void )

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


返回值:此函数返回一个浮点值,其中包含文本词间间距。

以下示例程序旨在说明PHP中的ImagickDraw::getTextInterwordSpacing()函数:

示例1:

<?php 
  
// Create a new ImagickDraw object 
$draw = new ImagickDraw(); 
  
// Get the text interword spacing 
$textInterwordSpacing = $draw->getTextInterwordSpacing(); 
echo $textInterwordSpacing; 
?>

输出:

0 // Which is the default value

示例2:

<?php 
  
// Create a new ImagickDraw object 
$draw = new ImagickDraw(); 
  
// Get the text interword spacing 
$draw->setTextInterWordSpacing(30); 
  
// Get the text interword spacing 
$textInterwordSpacing = $draw->getTextInterwordSpacing(); 
echo $textInterwordSpacing; 
?>

输出:

30

示例3:

<?php 
  
// Create a new imagick object 
$imagick = new Imagick(); 
  
// Create a image on imagick object 
$imagick->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



相关用法


注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | ImagickDraw getTextInterwordSpacing() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。