ImagickDraw::getTextEncoding()函數是PHP中的內置函數,用於獲取用於文本注釋的代碼集。這些代碼集告訴計算機如何將原始零和一解釋為實字符。通常,它們產生相同的文本,但使用不同的代碼集。
用法:
string ImagickDraw::getTextEncoding( void )
參數:此函數不接受任何參數。
返回值:此函數返回包含文本編碼的字符串值。
異常:該函數在錯誤時引發ImagickException。
下麵給出的程序說明了PHP中的ImagickDraw::getTextEncoding()函數:
示例1:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Get the text encoding
$textEncoding = $draw->getTextEncoding();
echo $textEncoding;
?>
輸出:
// Empty string which is the default value
示例2:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the text encoding
$draw->setTextEncoding('UTF-8');
// Get the text encoding
$textEncoding = $draw->getTextEncoding();
echo $textEncoding;
?>
輸出:
UTF-8
示例3:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, 'white');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the font size
$draw->setFontSize(40);
// Set the text encoding
$draw->setTextEncoding('UTF-8');
// Annotate a text
$draw->annotation(50, 100,
'This line is encoded with '
. $draw->getTextEncoding());
// Set the text encoding
$draw->setTextEncoding('UTF-32');
// Annotate a text
$draw->annotation(50, 200,
'This line is encoded with '
. $draw->getTextEncoding());
// 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.gettextencoding.php
相關用法
- PHP GmagickDraw gettextencoding()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw popClipPath()用法及代碼示例
- PHP ImagickDraw popDefs()用法及代碼示例
- PHP ImagickDraw pushClipPath()用法及代碼示例
- PHP ImagickDraw pushDefs()用法及代碼示例
- PHP ImagickDraw clone()用法及代碼示例
- PHP ImagickDraw getFillRule()用法及代碼示例
- PHP ImagickDraw pathMoveToAbsolute()用法及代碼示例
- PHP ImagickDraw pathLineToHorizontalRelative()用法及代碼示例
- PHP ImagickDraw setFillPatternURL()用法及代碼示例
- PHP ImagickDraw pathLineToVerticalAbsolute()用法及代碼示例
- PHP ImagickDraw pathLineToVerticalRelative()用法及代碼示例
- PHP ImagickDraw pushPattern()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw getTextEncoding() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。