Syntax:bool Imagick::setFont (string $font)
Parameters:This function takes one parameter,
$font,which contains the name of the font file.
Return Value:This function returns TRUE if successful.
Extensions:this function needs to have the
extensionGD installed.Below programs illustrate
function Imagick::getFont()in PHP:
Program 1: < ? php
// Create a new imagick object
$imagick
=
new
Imagick();
// Use the setFont() function to set
// font using the .ttf font file. .Ttf
// file is in the same folder
$imagick
-> setFont (
’Windsong.ttf’
);
// Write signature in image format
$imagick
-> newPseudoImage (800, 350,
"caption: GeekforGeeks "
);
// Show output
$imagick
-> setformat (
’png’
);
header (
" Content-Type: image / png "
);
echo
$imagick
-> getImageBlob();
?>
Output: Program 2:
// Create new imagick object
$imagick
=
new
Imagick();
// Install the font - make sure the font file is .ttf
// located in the same folder
$imagick
-> setFont (
’FFF_Tusj.ttf’
);
// Write a title on the image
$imagick
-> newPseudoImage (800, 350,
"caption: GeekforGeeks "
);
// Show output
$imagick
-> setformat (
’png’
);
header (
"Content-Type: image / png"
);
echo
$imagick
-> getImageBlob();
?>
Output: Link: https://www.php.net/manual/en/imagick.setfont.php