php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51352 imagettftext left-aligns text inappropriately
Submitted: 2010-03-22 18:51 UTC Modified: 2010-03-24 04:58 UTC
From: gregor at hostgis dot com Assigned: tabe (profile)
Status: Duplicate Package: GD related
PHP Version: 5.2.13 OS: Linux, Slamd64 11.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gregor at hostgis dot com
New email:
PHP Version: OS:

 

 [2010-03-22 18:51 UTC] gregor at hostgis dot com
Description:
------------
When rotating text, imagettftext() aligns all of the letters and characters
to be flush with the left-hand side of their box. Under many rotation
conditions and particularly with punctuation that is not bottom-aligned
(apostrophes, dashes) this is very unpleasant.

The test script below demonstrates this very well.

This appears similar to bug # 51263 but is in PHP 5.2.13

Test script:
---------------
$image = imagecreatetruecolor(200,200);
$white = imagecolorallocate($image,255,255,255);
$black = imagecolorallocate($image,0,0,0);
$font = '/home/customers/tnassoc/public_html/php-library/fonts/arial.ttf';
imagefill($image, 0, 0, $white);

imagettftext($image, 10, -90,  50, 80, $black, $font, "Clock-Un'Wise" );
imagettftext($image, 10, 90, 150, 100, $black, $font,  "Counter-O'Clock"
);
imagettftext($image, 10,   0,  20, 20, $black, $font, "Normal-Text" );

header('Content-type: image/png');
imagepng($image);


Expected result:
----------------
Three sets of words:

0. Normal-Text should appear normal left-to-right.

1. Clock-Un'Wise should be rotated 90 degrees right, and otherwise be
normal and readable.

2. Counter-O'Clock should be rotated 90 degrees left, and otherwise be
normal and readable.


Actual result:
--------------
0. Unrotated text is fine.

1. All characters are shifted to the left, aligned to the bottom of the
text. This includes the apostrophe and dash, with very unpleasant results.

2. All characters are shifted to the left, aligned to the top of the text.
The dash is now at the top of the text instead of the middle, and the
letters don't line up anymore.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-24 04:58 UTC] tabe@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: tabe
 [2010-03-24 04:58 UTC] tabe@php.net
Thanks for your report.
Reproduced, and this bug seems a duplicate of #51263.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Mar 02 14:01:23 2021 UTC