php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29249 imagettfbbox / imagettfbbox returning wrong values w/ linebreaks
Submitted: 2004-07-19 03:24 UTC Modified: 2005-01-22 01:00 UTC
Votes:4
Avg. Score:4.5 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: kees at tweakers dot net Assigned:
Status: No Feedback Package: GD related
PHP Version: 5.0.0 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-07-19 03:24 UTC] kees at tweakers dot net
Description:
------------
The imagettfbbox / imagettftext should return an array with the boundaries on texts. This works fine with a single string, but if you use a multiline string (with \n in it) it fails to report the actual size, and returns the size / box of a single line.

The string _is_ writen normally on the image, ie; with a newline instead of an \n, but the sizes are wrong.

Reproduce code:
---------------
// string with a line break, try imagettftext, it'll put the correct string on the image, but return the wrong results
$bounds = imagettfbbox(8, 0, 'tahoma.ttf', 'j\nj');
print_r($bounds);

// no line break here, just a \ instead of a /, which is the same size.
$bounds = imagettfbbox(8, 0, 'tahoma.ttf', 'j/nj');
print_r($bounds);

Expected result:
----------------
The first line should return something like a box with an x/y of 3 / 26 (or close), the second result should return (and does ;)) an x/y box of 15 / 12.


Actual result:
--------------
Both will give the same result, a box of x: 15 y: 26.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-19 03:26 UTC] kees at tweakers dot net
Actual result should be:
--------------
Both will give the same result, a box of x: 15 y: 12.
 [2005-01-15 00:42 UTC] sniper@php.net
I think you need to pass the string with double quotes:

bounds = imagettfbbox(8, 0, 'tahoma.ttf', "j\nj");


 [2005-01-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-01-28 05:51 UTC] spam at dtdsoft dot com
This bug is still present in PHP 5.2.0 (Running on Windows XP) I am posting this to reactiveate the bug and make it known that it is still present.

~DtD
BTW> I fixed it by multiplying the height by 
substr_count($string,"\n")+1)
 [2012-11-16 09:37 UTC] cirus dot minor at free dot fr
Reproduced with php 5.3.10 on windows
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 16:01:29 2024 UTC