ImagickDraw::getTextInterlineSpacing()函數是PHP中的內置函數,用於獲取文本行距。數字越大,空間越大。默認間距為0。
用法:
float ImagickDraw::getTextInterlineSpacing( void )
參數:此函數不接受任何參數。
返回值:此函數返回一個浮點值,其中包含文本行距。
異常:該函數在錯誤時引發ImagickException。
以下示例程序旨在說明PHP中的ImagickDraw::getTextInterlineSpacing()函數:
示例1:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Get the text interline spacing
$textInterlineSpacing = $draw->getTextInterLineSpacing();
echo $textInterlineSpacing;
?>
輸出:
0 // Which is the default value
示例2:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the text interline spacing
$draw->setTextInterLineSpacing(50);
// Get the text interline spacing
$textInterlineSpacing = $draw->getTextInterLineSpacing();
echo $textInterlineSpacing;
?>
輸出:
50
示例3:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->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
相關用法
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP ImagickDraw destroy()用法及代碼示例
- PHP ImagickDraw getStrokeDashOffset()用法及代碼示例
- PHP ImagickDraw setTextEncoding()用法及代碼示例
- PHP ImagickDraw getTextEncoding()用法及代碼示例
- PHP ImagickDraw getFillRule()用法及代碼示例
- PHP ImagickDraw setClipPath()用法及代碼示例
- PHP ImagickDraw getClipPath()用法及代碼示例
- PHP ImagickDraw color()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw comment()用法及代碼示例
- PHP ImagickDraw polyline()用法及代碼示例
- PHP ImagickDraw pathMoveToRelative()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw getTextInterlineSpacing() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。