PHP | GmagickDraw getfontweight() Function
The GmagickDraw::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 GmagickDraw::getfontweight( void )
Parameters: This function doesn’t accept any parameters.
Return Value: This function returns an integer value containing the font weight.
Exceptions: This function throws GmagickDrawException on error.
Below given programs illustrate the GmagickDraw::getfontweight() function in PHP:
Program 1:
<?php
$draw = new GmagickDraw();
$fontWeight = $draw ->getfontweight();
echo $fontWeight ;
?>
|
Output:
0 // Which is the default value
Program 2:
<?php
$draw = new GmagickDraw();
$draw ->setfontweight(200);
$fontWeight = $draw ->getfontweight();
echo $fontWeight ;
?>
|
Output:
200
Used Image:
Program 3:
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->setFillColor( '#0E0E0E' );
$draw ->setfontsize(40);
$draw ->rectangle(-10, -10, 800, 400);
$draw ->setFillColor( 'white' );
$draw ->setFontWeight(900);
$draw ->annotate(50, 100,
'The Font weight here is '
. $draw ->getFontWeight() . '.' );
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagickdraw.getfontweight.php
Last Updated :
23 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...