Skip to content
Related Articles

Related Articles

PHP | GmagickDraw getfont() Function

Improve Article
Save Article
  • Last Updated : 23 Jan, 2020
Improve Article
Save Article

The GmagickDraw::getfont() function is an inbuilt function in PHP which is used to get the string specifying the font used when annotating with text.


string GmagickDraw::getfont( void )

Parameters: This function doesn’t accept any parameters.

Return Value: This function returns an string value containing the font.

Exceptions: This function throws GmagickDrawException on error.

Below given programs illustrate the GmagickDraw::getfont() function in PHP:

Program 1:

// Create a new GmagickDraw object 
$draw = new GmagickDraw(); 
// Get the font 
$font = $draw->getfont(); 
echo $font


Empty string which is the default font.

Used Image:

Program 2:

// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');
// Create a GmagickDraw object
$draw = new GmagickDraw();
// Set the color
// Draw rectangle for background
$draw->rectangle(-10, -10, 800, 400);
// Set the fill color
// Set the font size
// Set the font to a ttf file which should be
// placed in same folder where the program is.
// Annotate a text
$draw->annotate(50, 120, 'The Font here is '
    . $draw->getfont() . '.');
// Use of drawimage functeannotate
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();



My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!