Open In App

PHP | ImagickDraw getTextInterwordSpacing() Function

Last Updated : 20 Dec, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The ImagickDraw::getTextInterwordSpacing() function is an inbuilt function in PHP which is used to get the text inter-word spacing which means space between each word. The greater number contains the greater space. The default spacing is 0.

Syntax:

float ImagickDraw::getTextInterwordSpacing( void )

Parameters:This function doesn’t accepts any parameters.

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

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

Program 1:




<?php
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Get the text interword spacing
$textInterwordSpacing = $draw->getTextInterwordSpacing();
echo $textInterwordSpacing;
?>


Output:

0 // Which is the default value

Program 2:




<?php
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Get the text interword spacing
$draw->setTextInterWordSpacing(30);
  
// Get the text interword spacing
$textInterwordSpacing = $draw->getTextInterwordSpacing();
echo $textInterwordSpacing;
?>


Output:

30

Program 3:




<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, '#c0eb34');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Set the font size
$draw->setFontSize(20);
  
// Annotate a text
$draw->annotation(50, 80, "The text interterword spacing here is "
           . $draw->getTextInterwordSpacing());
  
// Set the text interword spacing
$draw->setTextInterwordSpacing(20);
  
// Annotate a text
$draw->annotation(50, 120, "The text interterword spacing here is "
            . $draw->getTextInterwordSpacing());
  
// Set the text interword spacing
$draw->setTextInterwordSpacing(35);
  
// Annotate a text
$draw->annotation(50, 160, "The text interterword spacing here is "
           . $draw->getTextInterwordSpacing());
  
// 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.gettextinterwordspacing.php



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads