PHP | GmagickDraw setfontstyle() Function
The GmagickDraw::setfontstyle() function is an inbuilt function in PHP which is used to set the font style to use when annotating with text. Style enumeration acts as a wild-card don’t care option.
Syntax:
public GmagickDraw::setfontstyle( $style ) : GmagickDraw
Parameters: This function accepts single parameter $style which is used to hold the value of font style as integer type.
STYLE constants: List of style constants are given below:
- Gmagick::STYLE_NORMAL (integer)
- Gmagick::STYLE_ITALIC (integer)
- Gmagick::STYLE_OBLIQUE (integer)
- Gmagick::STYLE_ANY (integer)
Return Value: This function return GmagickDraw object on success.
Below programs illustrate the GmagickDraw::setfontstyle() function in PHP:
Program 1:
<?php // Create an GmagickDraw object $draw = new GmagickDraw(); // Set the image filled color $draw->setFillColor('red'); // Set the Font Size $draw->setFontSize(40); // Set the Font Style $draw->setfontstyle(\Gmagick::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 Gmagick object $gmagick= new Gmagick(); // Set the image dimension $gmagick->newImage(350, 300, 'white'); // Set the image format $gmagick->setImageFormat("png"); // Draw the image $gmagick->drawImage($draw); header("Content-Type: image/png"); // Display the image echo $gmagick->getImageBlob(); ?> |
Output:

Program 2:
<?php // Create an GmagickDraw object $draw = new GmagickDraw(); // Set the image filled color $draw->setFillColor('black'); // Set the font size $draw->setFontSize(30); // Set Font Style $draw->setfontstyle(\Gmagick::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 Gmagick object $gmagick= new Gmagick(); // Set the image dimension $gmagick->newImage(350, 300, 'white'); // Set the image format $gmagick->setImageFormat("png"); // Draw the image $gmagick->drawImage($draw); header("Content-Type: image/png"); // Display the image echo $gmagick->getImageBlob(); ?> |
Output:

Reference: http://php.net/manual/en/gmagickdraw.setfontstyle.php
Recommended Posts:
- PHP | ImagickDraw setFontStyle() Function
- PHP | GmagickDraw point() Function
- PHP | GmagickDraw getfontsize() Function
- PHP | GmagickDraw scale() Function
- PHP | GmagickDraw line() Function
- PHP | GmagickDraw settextdecoration() Function
- PHP | GmagickDraw getstrokewidth() Function
- PHP | GmagickDraw getstrokeopacity() Function
- PHP | GmagickDraw setstrokeopacity() Function
- PHP | GmagickDraw setfontsize() Function
- PHP | GmagickDraw setfontweight() Function
- PHP | GmagickDraw setstrokewidth() Function
- PHP | GmagickDraw setfillopacity() Function
- PHP | GmagickDraw rectangle() Function
- PHP | GmagickDraw setstrokecolor() 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.



