The ImagickDraw::setTextInterwordSpacing() function is an inbuilt function in PHP which is used to used to set the text interword spacing which means nothing but space between each word. The greater the number the greater the space will be. The default spacing is 0.
Syntax:
bool ImagickDraw::setTextInterwordSpacing( float $spacing )
Parameters: This function accepts a single parameter $spacing which holds the text interword spacing.
Return Value: This function returns TRUE on success.
Below programs illustrate the ImagickDraw::setTextInterwordSpacing() function in PHP:
Program 1:
<?php // Create a new ImagickDraw object $draw = new ImagickDraw(); // Get the text interword spacing $draw ->setTextInterWordSpacing(40); // Get the text interword spacing $textInterwordSpacing = $draw ->getTextInterwordSpacing(); echo $textInterwordSpacing ; ?> |
Output:
40
Program 2:
<?php // Create a new imagick object $imagick = new Imagick(); // Create a image on imagick object $imagick ->newImage(800, 250, '#1cced4' ); // Create a new ImagickDraw object $draw = new ImagickDraw(); // Set the font size $draw ->setFontSize(50); // Set the text interword spacing $draw ->setTextInterwordSpacing(65); // Annotate a text $draw ->annotation(150, 140, "Geeks for Geeks" ); // 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.settextinterwordspacing.php