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::setFontSize() function in PHP:
Program 1:
<?php // Create an ImagickDraw object $draw = new ImagickDraw(); // Set the image filled color $draw->setFillColor('red'); // Set the Font size $draw->setFontSize(40); // Set the Font Family $draw->setFontFamily('Ubuntu-Mono'); // Set the text to be added $draw->annotation(30, 170, "GeeksForGeeks"); // Set the image filled color $draw->setFillColor('green'); // Set the font size $draw->setFontSize(30); // Set the Font Family $draw->setFontFamily('Open-Sans-Light-Italic'); // Set the text to be added $draw->annotation(30, 250, "Ubuntu-Mono"); // Create new imagick object $imagick = new Imagick(); // Set the image dimension $imagick->newImage(350, 300, 'white'); // Set the image formats $imagick->setImageFormat("png"); // Draw the image $imagick->drawImage($draw); header("Content-Type: image/png"); // Display the image echo $imagick->getImageBlob(); ?> |
Output:

Program 2:
<?php // Create an ImagickDraw object $draw = new ImagickDraw(); // set the image filled color $draw->setFillColor('Green'); // Set the font size $draw->setFontSize(30); // Set the Font Style $draw->setFontFamily('Ani'); // Set the text to be added $draw->annotation(30, 40, "GeeksForGeeks"); // Create new imagick object $imagick = new Imagick(); // Set the image dimension $imagick->newImage(250, 70, 'white'); // Set the iamge format $imagick->setImageFormat("png"); // Draw the image $imagick->drawImage($draw); header("Content-Type: image/png"); // Display the image echo $imagick->getImageBlob(); ?> |
Output:

Reference: http://php.net/manual/en/imagickdraw.setfontfamily.php
Recommended Posts:
- PHP | Spreadsheet_Excel_Writer | setFontFamily() Function
- PHP | ImagickDraw pop() Function
- PHP | ImagickDraw arc() Function
- PHP | ImagickDraw pathEllipticArcRelative() Function
- PHP | ImagickDraw pathLineToRelative() Function
- PHP | ImagickDraw pathFinish() Function
- PHP | ImagickDraw pathLineToHorizontalAbsolute() Function
- PHP | ImagickDraw pathLineToAbsolute() Function
- PHP | ImagickDraw pathMoveToRelative() Function
- PHP | ImagickDraw getTextUnderColor() Function
- PHP | ImagickDraw setTextInterwordSpacing() Function
- PHP | ImagickDraw getVectorGraphics() Function
- PHP | ImagickDraw pathCurveToAbsolute() Function
- PHP | ImagickDraw pathClose() Function
- PHP | ImagickDraw setVectorGraphics() Function
- PHP | ImagickDraw translate() Function
- PHP | ImagickDraw pathCurveToRelative() Function
- PHP | ImagickDraw pathCurveToSmoothAbsolute() Function
- PHP | ImagickDraw setFont() Function
- PHP | ImagickDraw pathCurveToQuadraticBezierSmoothAbsolute() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

