PHP | ImagickDraw setFontStyle() Function
The ImagickDraw::setFontStyle() function is an inbuilt function in PHP which is used to set the font style to use when annotating with text. The AnyStyle enumeration acts as a wild-card “don’t care” option.
Syntax:
bool ImagickDraw::setFontStyle( $style )
Parameters: This function accepts a single parameter $style which is used to hold the value of font style as integer type.
STYLE constants:
- imagick::STYLE_NORMAL (integer)
- imagick::STYLE_ITALIC (integer)
- imagick::STYLE_OBLIQUE (integer)
- imagick::STYLE_ANY (integer)
Return Value: This function does not return any value.
Below programs illustrate the ImagickDraw::setFontStyle() 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 Style $draw->setFontStyle(\Imagick::STYLE_OBLIQUE); // 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 text to be added $draw->annotation(30, 250, "Oblique Style"); // Create new Imagick object $imagick = new Imagick(); // Set the image dimension $imagick->newImage(350, 300, 'white'); // Set the image format $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('black'); // Set the font size $draw->setFontSize(30); // Set Font Style $draw->setFontStyle(\Imagick::STYLE_ITALIC); // Set the text to be added $draw->annotation(30, 170, "GeeksForGeeks"); // Set the image filled color $draw->setFillColor('blue'); // Set the font size $draw->setFontSize(25); // Set the text to be added $draw->annotation(30, 250, "Italic Style"); // Create new Imagick object $imagick = new Imagick(); // Set the image dimension $imagick->newImage(350, 300, 'white'); // Set the image 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.setfontstyle.php
Recommended Posts:
- PHP | GmagickDraw setfontstyle() Function
- PHP | ImagickDraw arc() Function
- PHP | ImagickDraw setFont() Function
- PHP | ImagickDraw setFontFamily() Function
- PHP | ImagickDraw setFontSize() Function
- PHP | ImagickDraw setFillOpacity() Function
- PHP | ImagickDraw setStrokeMiterLimit() Function
- PHP | ImagickDraw scale() Function
- PHP | ImagickDraw circle() Function
- PHP | ImagickDraw setFontWeight() Function
- PHP | ImagickDraw skewX() Function
- PHP | ImagickDraw polygon() Function
- PHP | ImagickDraw roundRectangle() Function
- PHP | ImagickDraw setStrokeWidth() Function
- PHP | ImagickDraw setFillColor() 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.



