HomeLanguagesPHP | ImagickDraw setTextInterwordSpacing() Function

PHP | ImagickDraw setTextInterwordSpacing() Function

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

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

3 COMMENTS

Most Popular

Dominic
32743 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7129 POSTS0 COMMENTS
Nicole Veronica
12258 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12341 POSTS0 COMMENTS
Shaida Kate Naidoo
7240 POSTS0 COMMENTS
Ted Musemwa
7501 POSTS0 COMMENTS
Thapelo Manthata
7219 POSTS0 COMMENTS
Umr Jansen
7189 POSTS0 COMMENTS