The ImagickDraw::setFontFamily() function is an inbuilt function in PHP which is used to set the font family to use when annotating with text.
Syntax:
bool ImagickDraw::setFontFamily( $font_family )
Parameters:This function accepts a single parameter $font_family which is used to hold the value of font family as string.
Return Value: This function returns True on success.
Below programs illustrate the ImagickDraw::setFontFamily() function in PHP:
Program 1:
PHP
<?php
$draw = new ImagickDraw();
$draw ->setFillColor( 'red' );
$draw ->setFontSize(40);
$draw ->setFontFamily( 'Ubuntu-Mono' );
$draw ->annotation(30, 170, "GeeksForGeeks" );
$draw ->setFillColor( 'green' );
$draw ->setFontSize(30);
$draw ->setFontFamily( 'Open-Sans-Light-Italic' );
$draw ->annotation(30, 250, "Ubuntu-Mono" );
$imagick = new Imagick();
$imagick ->newImage(350, 300, 'white' );
$imagick ->setImageFormat( "png" );
$imagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:

Program 2:
PHP
<?php
$draw = new ImagickDraw();
$draw ->setFillColor( 'Green' );
$draw ->setFontSize(30);
$draw ->setFontFamily( 'Ani' );
$draw ->annotation(30, 40, "GeeksForGeeks" );
$imagick = new Imagick();
$imagick ->newImage(250, 70, 'white' );
$imagick ->setImageFormat( "png" );
$imagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:

Reference: http://php.net/manual/en/imagickdraw.setfontfamily.php
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
11 Aug, 2021
Like Article
Save Article