PHP | GmagickDraw getfont() Function
Last Updated :
23 Jan, 2020
The GmagickDraw::getfont() function is an inbuilt function in PHP which is used to get the string specifying the font used when annotating with text.
Syntax:
string GmagickDraw::getfont( void )
Parameters: This function doesn’t accept any parameters.
Return Value: This function returns an string value containing the font.
Exceptions: This function throws GmagickDrawException on error.
Below given programs illustrate the GmagickDraw::getfont() function in PHP:
Program 1:
<?php
$draw = new GmagickDraw();
$font = $draw ->getfont();
echo $font ;
?>
|
Output:
Empty string which is the default font.
Used Image:
Program 2:
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->setFillColor( '#0E0E0E' );
$draw ->rectangle(-10, -10, 800, 400);
$draw ->setFillColor( 'yellow' );
$draw ->setFontSize(20);
$draw ->setFont( 'Pacifico.ttf' );
$draw ->annotate(50, 120, 'The Font here is '
. $draw ->getfont() . '.' );
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagickdraw.getfont.php
Share your thoughts in the comments
Please Login to comment...