ImagickDraw::setFontWeight()函數是PHP中的一個內置函數,用於設置字體粗細。
用法:
bool ImagickDraw::setFontWeight( $font_weight )
參數:該函數接受單個參數$font_weight,該參數用於將字體粗細的值保存為整數類型。
返回值:成功時此函數返回True。
以下示例程序旨在說明PHP中的ImagickDraw::setFontWeight()函數:
程序1:
<?php
// Create an ImagickDraw object
$draw = new ImagickDraw();
// Set the image filled color
$draw->setFillColor('red');
// Set the Font Weight
$draw->setFontWeight(200);
// Set the font size
$draw->setFontSize(40);
// Set the font family
$draw->setFontFamily('Ubuntu-Mono');
// Set the text to be added
$draw->annotation(30, 170, "GeeksForGeeks");
// Set the image filled color
$draw->setFillColor('green');
// Set the Font Stretch
$draw->setFontStretch(3);
// Set the font size
$draw->setFontSize(30);
// Set the font family
$draw->setFontFamily('Open-Sans-Light-Italic');
// Set the text to be added
$draw->annotation(30, 250, "Font-Weight : 200");
// Create new imagick object
$imagick = new Imagick();
// Set the image dimension
$imagick->newImage(350, 300, 'white');
// Set the image format
$imagick->setImageFormat("png");
// Draw the image
$imagick->drawImage($draw);
header("Content-Type: image/png");
// Display the image
echo $imagick->getImageBlob();
?>
輸出:
程序2:
<?php
// Create an ImagickDraw object
$draw = new ImagickDraw();
// Set the image filled color
$draw->setFillColor('Green');
// Set the font size
$draw->setFontSize(30);
// Set the Font Weight
$draw->setFontWeight(400);
// Set the font family
$draw->setFontFamily('Ani');
// Set the text to be added
$draw->annotation(30, 40, "GeeksForGeeks");
// Create new Imagick object
$imagick = new Imagick();
// Set the image dimension
$imagick->newImage(250, 70, 'white');
// Set the image format
$imagick->setImageFormat("png");
// Draw the image
$imagick->drawImage($draw);
header("Content-Type: image/png");
// Display the image
echo $imagick->getImageBlob();
?>
輸出:
參考: http://php.net/manual/en/imagickdraw.setfontweight.php
相關用法
- PHP GmagickDraw setfontweight()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP ImagickDraw pushClipPath()用法及代碼示例
- PHP ImagickDraw pathClose()用法及代碼示例
- PHP ImagickDraw rotate()用法及代碼示例
- PHP ImagickDraw pathCurveToAbsolute()用法及代碼示例
- PHP ImagickDraw skewY()用法及代碼示例
- PHP ImagickDraw setStrokeLineJoin()用法及代碼示例
- PHP ImagickDraw popClipPath()用法及代碼示例
- PHP ImagickDraw pathCurveToSmoothAbsolute()用法及代碼示例
- PHP ImagickDraw setClipUnits()用法及代碼示例
- PHP ImagickDraw getFillColor()用法及代碼示例
- PHP ImagickDraw getTextKerning()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 PHP | ImagickDraw setFontWeight() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。