函式:ImagickDraw::setTextKerning()
描述:設定文字字距(字元之間的空間)
用法:以下是使用ImagickDraw::setTextKerning()函式的基本用法:
bool ImagickDraw::setTextKerning ( float $kerning )
引數:
$kerning
:要設定的文字字距值,以浮點數表示。預設值為0。
返回值:
- 成功時返回true,失敗時返回false。
示例:
// 建立一個ImagickDraw物件
$draw = new ImagickDraw();
// 設定字型大小
$draw->setFontSize(20);
// 設定文字字距為2
$draw->setTextKerning(2);
// 在影象上繪製帶有字距的文字
$draw->annotation(50, 50, "Hello World");
// 建立一個Imagick物件並載入背景影象
$image = new Imagick();
$image->readImage('background.jpg');
// 將繪製物件應用於影象
$image->drawImage($draw);
// 顯示影象
header("Content-Type: image/png");
echo $image;
在上面的示例中,我們首先建立了一個ImagickDraw物件並設定了字型大小為20。然後,我們使用setTextKerning()
函式將文字字距設定為2。接下來,我們使用annotation()
函式在影象上繪製帶有字距的文字。最後,我們建立一個Imagick物件並載入背景影象,然後將繪製物件應用於影象並將其顯示出來。
請注意,setTextKerning()
函式的引數值可以為正數(增加字距)或負數(減少字距),具體取決於您的需求。