PHP | GmagickDraw setfont() function
The GmagickDraw::setfont() function is an inbuilt function in PHP which is used to set the fully-specified font to use when annotating with text.
Syntax:
GmagickDraw GmagickDraw::setfont( string $font )
Parameters:This function accepts a single parameter $font which is used to hold the value of font name as string.
Return Value: This function returns GmagickDraw object on success.
Exceptions: This function throws GmagickDrawException on error.
Below given programs illustrate the GmagickDraw::setfont() function in PHP:
Program 1:
<?php
$draw = new GmagickDraw();
$draw ->setfont( 'roboto.ttf' );
$font = $draw ->getfont();
echo $font ;
?>
|
Output:
/home/user/php/roboto.ttf
Program 2:
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->rectangle(-100, -1000, 800, 400);
$draw ->setfontsize(90);
$draw ->setstrokecolor( 'red' );
$draw ->setfont( 'Pacifico.ttf' );
$draw ->annotate(20, 110, 'GeeksforGeeks' );
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagickdraw.setfont.php
Last Updated :
23 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...