PHP | GmagickDraw setfontstyle() Function
Last Updated :
28 Apr, 2023
The GmagickDraw::setfontstyle() function is an inbuilt function in PHP that 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 a single parameter $style which is used to hold the value of font style as integer type.
STYLE constants: A list of style constants is given below:
- Gmagick::STYLE_NORMAL (integer)
- Gmagick::STYLE_ITALIC (integer)
- Gmagick::STYLE_OBLIQUE (integer)
- Gmagick::STYLE_ANY (integer)
Return Value: This function returns the GmagickDraw object on success. The below programs illustrate the GmagickDraw::setfontstyle() function in PHP.
Program 1:
php
<?php
$draw = new GmagickDraw();
$draw ->setFilledColor( 'red' );
$draw ->setFontSize(40);
$draw ->setfontstyle(\Gmagick::STYLE_OBLIQUE);
$draw ->annotation(30, 170, "GeeksForGeeks");
$draw ->setFilledColor( 'green' );
$draw ->setFontSize(30);
$draw ->annotation(30, 250, "Oblique Style");
$gmagick = new Gmagick();
$gmagick ->newImage(350, 300, 'white' );
$gmagick ->setImageFormat("png");
$gmagick ->drawImage( $draw );
header("Content-Type: image/png");
echo $gmagick ->getImageBlob();
?>
|
Output:
Program 2:
php
<?php
$draw = new GmagickDraw();
$draw ->setFilledColor( 'black' );
$draw ->setFontSize(30);
$draw ->setfontstyle(\Gmagick::STYLE_ITALIC);
$draw ->annotation(30, 170, "GeeksForGeeks");
$draw ->setFilledColor( 'blue' );
$draw ->setFontSize(25);
$draw ->annotation(30, 250, "Italic Style");
$gmagick = new Gmagick();
$gmagick ->newImage(350, 300, 'white' );
$gmagick ->setImageFormat("png");
$gmagick ->drawImage( $draw );
header("Content-Type: image/png");
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: http://php.net/manual/en/gmagickdraw.setfontstyle.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...