Skip to content
Related Articles

Related Articles

PHP | ImagickDraw getTextInterlineSpacing() Function
  • Last Updated : 20 Dec, 2019

The ImagickDraw::getTextInterlineSpacing() function is an inbuilt function in PHP which is used to get the text interline spacing. The greater the number the greater the space will be. Default spacing is 0.

Syntax:

float ImagickDraw::getTextInterlineSpacing( void )

Parameters: This function doesn’t accepts any parameters.

Return Value: This function returns an float value containing text interline spacing.

Exceptions: This function throws ImagickException on error.



Below programs illustrate the ImagickDraw::getTextInterlineSpacing() function in PHP:

Program 1:




<?php
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Get the text interline spacing
$textInterlineSpacing = $draw->getTextInterLineSpacing();
echo $textInterlineSpacing;
?>


Output:

0 // Which is the default value

Program 2:




<?php
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Set the text interline spacing
$draw->setTextInterLineSpacing(50);
  
// Get the text interline spacing
$textInterlineSpacing = $draw->getTextInterLineSpacing();
echo $textInterlineSpacing;
?>


Output:

50

Program 3:




<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, 'brown');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Set the fill color
$draw->setFillColor('white');
  
// Set the font size
$draw->setFontSize(20);
  
// Annotate a text
$draw->annotation(50, 100, "The text interterline \nspacing here is "
            . $draw->getTextInterLineSpacing());
  
// Set the text interline spacing
$draw->setTextInterLineSpacing(30);
  
// Annotate a text
$draw->annotation(300, 100, "The text interterline \nspacing here is "
            . $draw->getTextInterLineSpacing());
  
// Set the text interline spacing
$draw->setTextInterLineSpacing(50);
  
// Annotate a text
$draw->annotation(550, 100, "The text interterline \nspacing here is "
            . $draw->getTextInterLineSpacing());
  
// Render the draw commands
$imagick->drawImage($draw);
  
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>


Output:

Reference: https://www.php.net/manual/en/imagickdraw.gettextinterlinespacing.php

My Personal Notes arrow_drop_up
Recommended Articles
Page :