PHP | ImagickDraw getFontWeight() Function
Last Updated :
17 Dec, 2019
The ImagickDraw::getFontWeight() function is an inbuilt function in PHP which is used to get the font-weight used when annotating with text. Font weight actually signifies the boldness of the font, more the font-weight the more the bold text will be. It can be anything from 100 to 900.
Syntax:
int ImagickDraw::getFontWeight( void )
Parameters: This function doesn’t accept any parameter.
Return Value: This function returns an integer value containing the font weight or 0 when no weight is set.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the ImagickDraw::getFontWeight() function in PHP:
Program 1:
<?php
$draw = new ImagickDraw();
$fontWeight = $draw ->getFontWeight();
echo $fontWeight ;
?>
|
Output:
0 // which is the default value.
Program 2:
<?php
$draw = new ImagickDraw();
$draw ->setFontWeight(110);
$fontWeight = $draw ->getFontWeight();
echo $fontWeight ;
?>
|
Output:
110
Program 3:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, '#bfc7d6' );
$draw = new ImagickDraw();
$draw ->setFontSize(30);
$draw ->annotation(50, 100,
'The Font weight here is default.' );
$draw ->setFontWeight(900);
$draw ->annotation(50, 200,
'The Font weight here is '
. $draw ->getFontWeight() . '.' );
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.getfontweight.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...