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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
28 Apr, 2023
Like Article
Save Article