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
相關用法
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP ImagickDraw destroy()用法及代碼示例
- PHP ImagickDraw getStrokeDashOffset()用法及代碼示例
- PHP ImagickDraw setTextEncoding()用法及代碼示例
- PHP ImagickDraw getTextEncoding()用法及代碼示例
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP ImagickDraw getFillRule()用法及代碼示例
- PHP ImagickDraw setClipPath()用法及代碼示例
- PHP ImagickDraw getClipPath()用法及代碼示例
- PHP ImagickDraw color()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw comment()用法及代碼示例
- PHP ImagickDraw polyline()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw getTextInterwordSpacing() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。