Edit report at https://bugs.php.net/bug.php?id=81617&edit=1
ID: 81617
Updated by: cmb@php.net
Reported by: dwhile at while dot org dot uk
Summary: text with 90 degree angle not rendered correctly
-Status: Assigned
+Status: Suspended
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:
I'm suspending this ticket until the upstream issue[1] is closed.
[1] <https://github.com/libgd/libgd/issues/790>
Previous Comments:
------------------------------------------------------------------------
[2021-11-12 13:49:27] cmb@php.net
> Output can be seen at <https://www.while.org.uk/try.png>
That is indeed broken. Anyhow, this looks very much like an
upstream issue, so please report there[1]. But before, also check
whether that happens with other fonts as well, and if possible,
try with GD 2.3.3 or even their master HEAD. Also mention the
freetype version you are using.
[1] <https://github.com/libgd/libgd/issues>
------------------------------------------------------------------------
[2021-11-12 12:50:13] dwhile at while dot org dot uk
I have copied your code (and changed the font path to the relevant Linux format.
Output can be seen at <https://www.while.org.uk/try.png>
------------------------------------------------------------------------
[2021-11-12 12:42:01] dwhile at while dot org dot uk
Yes the text characters are overlayed on top of each other.
GD version is 2.3.2
------------------------------------------------------------------------
[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