Bug #81617 [Fbk->Asn]: text with 90 degree angle not rendered correctly
| From: | dwhile at while dot org dot uk | Date: | Fri, 12 Nov 2021 12:42:01 +0000 |
| Subject: | Bug #81617 [Fbk->Asn]: text with 90 degree angle not rendered correctly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237723@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81617&edit=1
ID: 81617
User updated by: dwhile at while dot org dot uk
Reported by: dwhile at while dot org dot uk
Summary: text with 90 degree angle not rendered correctly
-Status: Feedback
+Status: Assigned
Type: Bug
Package: GD related
Operating System: Linux
PHP Version: 8.0.12
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Yes the text characters are overlayed on top of each other.
GD version is 2.3.2
Previous Comments:
------------------------------------------------------------------------
[2021-11-12 12:37:21] cmb@php.net
To clarify, the following slightly modified example
<?php
$im = imagecreatetruecolor(30, 300);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 29, 299, $white);
$text = 'Testing...';
$font = 'C:/Windows/Fonts/Arial.ttf';
imagettftext($im, 20, 90, 26, 221, $grey, $font, $text);
imagettftext($im, 20, 90, 25, 220, $black, $font, $text);
imagepng($im, __DIR__ . "/81617.png");
?>
should give something like <https://imgur.com/a/kH8JmNG>.
It is expected that the text is rendered from bottom to top; if
you want it the other way, use an angle of 270°.
However, if I understand you correctly, in your case the
letters are overlayed. Which GD version do you use?
------------------------------------------------------------------------
[2021-11-12 11:52:38] dwhile at while dot org dot uk
Description:
------------
Using the imagettftext function call with an angle of 90 degrees causes the output to be rendered
with each letter of the text on top of one another.
Using the example from the documentation page and changing the angle to 90 causes the problem indeed
anything above around 45 degrees shows the same problem.
Test script:
---------------
<?php
header('Content-Type: image/png');
$im = imagecreatetruecolor(400, 30);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
$text = 'Testing...';
$font = '/usr/share/fonts/msttcorefonts/arial.ttf';
imagettftext($im, 20, 90, 11, 21, $grey, $font, $text);
imagettftext($im, 20, 90, 10, 20, $black, $font, $text);
imagepng($im);
imagedestroy($im);
?>
Expected result:
----------------
The text should be rendered vertically reading from bottom to top.
Actual result:
--------------
The rendered text has each character rendered on top of each other.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81617&edit=1