Friday, January 10, 2025
Google search engine
HomeLanguagesPHP | ImagickDraw getTextInterwordSpacing() Function

PHP | ImagickDraw getTextInterwordSpacing() Function

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen 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!

RELATED ARTICLES

Most Popular

Recent Comments