GmagickDraw::setfontweight()函數是PHP中的內置函數,用於設置字體粗細。
用法:
public GmagickDraw::setfontweight( $font_weight ) : GmagickDraw
參數:該函數接受單個參數$font_weight,該參數用於將字體粗細的值保存為整數類型。
返回值:成功時,此函數返回GmagickDraw對象。
以下示例程序旨在說明PHP中的GmagickDraw::setfontweight()函數:
程序1:
<?php
// Create an GmagickDraw object
$draw = new GmagickDraw();
// 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 gmagick object
$gmagick = new Gmagick();
// Set the image dimension
$gmagick->newImage(350, 300, 'white');
// Set the image format
$gmagick->setImageFormat("png");
// Draw the image
$gmagick->drawImage($draw);
header("Content-Type: image/png");
// Display the image
echo $gmagick->getImageBlob();
?>
輸出:
程序2:
<?php
// Create an GmagickDraw object
$draw = new GmagickDraw();
// 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 Gmagick object
$gmagick= new Gmagick();
// Set the image dimension
$gmagick->newImage(250, 70, 'white');
// Set the image format
$gmagick->setImageFormat("png");
// Draw the image
$gmagick->drawImage($draw);
header("Content-Type: image/png");
// Display the image
echo $gmagick->getImageBlob();
?>
輸出:
參考: http://php.net/manual/en/gmagickdraw.setfontweight.php
相關用法
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP GmagickDraw arc()用法及代碼示例
- PHP GmagickDraw ellipse()用法及代碼示例
- PHP GmagickDraw rectangle()用法及代碼示例
- PHP GmagickDraw gettextencoding()用法及代碼示例
- PHP GmagickDraw gettextdecoration()用法及代碼示例
- PHP GmagickDraw bezier()用法及代碼示例
- PHP GmagickDraw getfillcolor()用法及代碼示例
- PHP GmagickDraw getstrokeopacity()用法及代碼示例
- PHP GmagickDraw getstrokewidth()用法及代碼示例
- PHP GmagickDraw getfontsize()用法及代碼示例
- PHP GmagickDraw roundrectangle()用法及代碼示例
- PHP GmagickDraw point()用法及代碼示例
- PHP GmagickDraw line()用法及代碼示例
- PHP GmagickDraw setfontsize()用法及代碼示例
注:本文由純淨天空篩選整理自R_Raj大神的英文原創作品 PHP | GmagickDraw setfontweight() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。