PHP | imagickdraw setFontSize()函数
ImagickDraw::setFontSize()函数是PHP中的一个内置函数,用于设置字体点的大小。它在用文本注释时使用。
句法:
bool ImagickDraw::setFontSize( $pointsize )
参数:此函数接受单个参数$pointsize ,用于保存点大小的值。
返回值:此函数不返回任何值。
下面的程序说明了PHP中的ImagickDraw::setFontSize()函数:
方案一:
php
setFillColor('Green');
// Set the Font Size
$draw->setFontSize(30);
// 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();
?>
php
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 format
$imagick->setImageFormat("png");
// Draw the image
$imagick->drawImage($draw);
header("Content-Type: image/png");
// Display the image
echo $imagick->getImageBlob();
?>
输出:
方案二:
PHP
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 format
$imagick->setImageFormat("png");
// Draw the image
$imagick->drawImage($draw);
header("Content-Type: image/png");
// Display the image
echo $imagick->getImageBlob();
?>
输出:
参考: http: PHP。 PHP