ImagickDraw::setFontFamily()函數是PHP中的內置函數,用於設置在用文本注釋時使用的字體係列。
用法:
bool ImagickDraw::setFontFamily( $font_family )
參數:該函數接受單個參數$font_family,該參數用於將字體係列的值保存為字符串。
返回值:成功時此函數返回True。
以下示例程序旨在說明PHP中的ImagickDraw::setFontSize()函數:
程序1:
<?php
// Create an ImagickDraw object
$draw = new ImagickDraw();
// Set the image filled color
$draw->setFillColor('red');
// 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 size
$draw->setFontSize(30);
// Set the Font Family
$draw->setFontFamily('Open-Sans-Light-Italic');
// Set the text to be added
$draw->annotation(30, 250, "Ubuntu-Mono");
// Create new imagick object
$imagick = new Imagick();
// Set the image dimension
$imagick->newImage(350, 300, 'white');
// Set the image formats
$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 Style
$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 iamge 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.setfontfamily.php
相關用法
- PHP Spreadsheet_Excel_Writer setFontFamily()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw pathCurveToQuadraticBezierSmoothRelative()用法及代碼示例
- PHP ImagickDraw pathMoveToAbsolute()用法及代碼示例
- PHP ImagickDraw getFont()用法及代碼示例
- PHP ImagickDraw setTextKerning()用法及代碼示例
- PHP ImagickDraw setTextInterlineSpacing()用法及代碼示例
- PHP ImagickDraw getTextInterwordSpacing()用法及代碼示例
- PHP ImagickDraw clone()用法及代碼示例
- PHP ImagickDraw setFillOpacity()用法及代碼示例
- PHP ImagickDraw setTextAntialias()用法及代碼示例
- PHP ImagickDraw pathEllipticArcAbsolute()用法及代碼示例
- PHP ImagickDraw setTextEncoding()用法及代碼示例
- PHP ImagickDraw comment()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 PHP | ImagickDraw setFontFamily() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。