[libGD] #80 [Comment added] bounds returned by stringFT sometimes clips a few pixels off the right

[email protected] (libGD)
Newsgroups php.gd.bugs
Message-ID <[email protected]>
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

The following task has a new comment added:

FS#80 - bounds returned by stringFT sometimes clips a few pixels off the right
User who did this - Colen Garoutte-Carson (Colen)

----------
I see this with freetype 2.3.4.  I'm making 2 calls to stringFT.  First I get the bounds and figure out the height and width like so (in Perl) :

<code>@bounds = GD::Image->stringFT($fg, $font, $pt, $rot, 0, 0, $text);

$left = &min($bounds[0], &min($bounds[2], &min($bounds[4], $bounds[6]))); #in case rotated
$right = &max($bounds[0], &max($bounds[2], &max($bounds[4], $bounds[6])));
$top = &min($bounds[1], &min($bounds[3], &min($bounds[5], $bounds[7])));
$bottom = &max($bounds[1], &max($bounds[3], &max($bounds[5], $bounds[7])));
$width = $right - $left;
$height = $bottom - $top;
</code>
Then I create an image and move the origin.  Since the origin was 0,0 the first time, -$left is the # of pixels needed left of the origin, and -$top is # of pixels needed above the origin.

<code>
# when not rotated
$xpos = -$left;
$ypos = -$top;
</code>

(Actually, I do something slightly less efficient, to determine the maximum descent.  Is there a way to read that from the font directly?)

<code>
$im = new GD::Image($width, $height);
@bounds2 = $im->stringFT($fg, $font, $pt, $rot, $xpos, $ypos, $text);
</code>

For the images I had atteched, I doubled the height and width, and drew lines with the bounds returned by the second call to stringFT.

I've never seen descending bits clipped (j's and g's), only the far right of right-leaning or fancy fonts.

 - Colen


----------

More information can be found at the following URL:
http://bugs.libgd.org/?do=details&task_id=80#comment233

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.