Posted by sittard on June 17, 2009 at 10:04am
Jump to:
| Project: | Textimage |
| Version: | 6.x-2.1 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed |
Issue Summary
Is it possible to adjust the leading (the vertical space between lines of text) ?
Comments
#1
Not at this stage, but it is something that I would like to implement in the future.
#2
Looking forward to seeing that - thanks for the quick reply!
#3
Any progress on this?
#4
I have absolutely zero time to work on textimage at the moment, but I would be happy to accept patches.
#5
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]);
}
#6
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
}
}
#7
I have been working on Textimage 3.0 for sometime now and I can confirm that this feature will be included.
Cheers,
Deciphered.
#8
I haven't yet come across a need for leading, but I found this issue when looking for tracking adjustment.
@sunchaser: that code was useful, thanks. As I mention in another issue (specifically asking about letter-spacing: http://drupal.org/node/891196#comment-3483982), I hacked this into my own version to just deal with tracking--but there seems to be a kerning issue.
It's possible it isn't a kerning issue, but something else. Just wanted to raise the issue here, as well, as the features (leading/tracking/kerning) are closely related.
If GD can't manage this, then I understand there's not a lot Textimage can do.
Thanks.
#9
$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
}
}
This works pretty good, the spacing between letters are not perfect but fairly good. The main problem is that the image is not resized according to the leading, resulting that if you have more than 1 line of text, a large blank space is added underneath the the text in the image.