Adjust Leading

sittard - June 17, 2009 - 10:04
Project:Textimage
Version:6.x-2.1
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed
Description

Is it possible to adjust the leading (the vertical space between lines of text) ?

#1

Deciphered - June 17, 2009 - 10:14
Category:support request» feature request
Status:active» postponed

Not at this stage, but it is something that I would like to implement in the future.

#2

sittard - June 17, 2009 - 12:58

Looking forward to seeing that - thanks for the quick reply!

#3

obrigado - September 9, 2009 - 05:45

Any progress on this?

#4

Deciphered - September 9, 2009 - 07:42

I have absolutely zero time to work on textimage at the moment, but I would be happy to accept patches.

#5

sunchaser - October 26, 2009 - 14:32

got my Leading up and running ...
haven't implemented anything in the admin yet , but straight up, HARDCODED into the module code cause I needed it fast.

maybe someone else can work on the admin part so you can adjust leading dynamically ...

so, in the module around line 746 replace this line : imagettftext($image, $fontsize, $q_angle, $x, $y, $fore, $font, $text);
by this block

  $lines=explode("\n",$text);
  for($i=0; $i< count($lines); $i++)
    {
    $newY=$y+($i * $fontsize * 1.2); //this 1.2 is the leading factor which you can set accordingly
    imagettftext($image, $fontsize, $q_angle, $x, $newY, $fore, $font,  $lines[$i]);
    }

Be sure to flush caches to see the changes

#6

sunchaser - October 26, 2009 - 22:35

worked a bit more on this
it seemed I needed to make some changes in the character spacing (tracking) too ...

$lines=explode("\n",$text);
  for($i=0; $i< count($lines); $i++)
  {
      $x = 0; //init $x pos to zero for each new line.
      $newY=$y+($i * $fontsize * 1.2); //this 1.2 is the leading factor which you can set accordingly
      for ($j = 0; $j <strlen($lines[$i]); $j++) {
           $arr = imagettftext($image, $fontsize, $q_angle, $x, $newY, $fore, $font,  $lines[$i]{$j});
           $x = $arr[4]+0; //this 0 is the tracking coefficient ... put in any other number to see the difference
      }
  }

 
 

Drupal is a registered trademark of Dries Buytaert.