Describe the bug
php-gd (and thus libgd3 library on Debian/Ubuntu repos) does not connect Persian/Arabic characters properly. This is while the same sample code provided below shows a properly connected Persian/Arabic characters when running the same version of php and libgd from remi repo.
To Reproduce
Steps to reproduce the behavior:
Install php-gd library
Run the following sample code which takes sample text "سلام", uses Lateef truetype font from Google Apis which supports Arabic/Persian characters to convert this text to an image and displays it online:
// Create a new image with width and height
$width = 200;$height = 50;
$image = imagecreatetruecolor($width, $height);
// Allocate colors for text and background
$bg_color = imagecolorallocate($image, 255, 255, 255); // white background
$text_color = imagecolorallocate($image, 0, 0, 0); // black text
// Fill the background with white
imagefilledrectangle($image, 0, 0, $width, $height, $bg_color);
// Add text to the image
$text = "سلام";
$font_size = 32;$text_x = 10;$text_y = 30;
// Add text using TrueType font
imagettftext($image, $font_size, 0, $text_x, $text_y, $text_color, $font_path, $text);
// Output the image as JPEG
imagejpeg($image);
// Free up memory
imagedestroy($image);
// Remove the downloaded font file
unlink($font_file);
?>
3. On Debian builts you'll see disconnected characters in wrong left to right direction like the following image:
![image](https://github.com/oerdnj/deb.sury.org/assets/10244293/95dc55b5-d87b-41bf-b014-57699bbd0a39)
**Your understanding of what is happening**
As per my research, gd library needs to be compiled with Complex text support to support it. Gd depends on libraqm to support Persian/Arabic characters. I assume the underlying library is not using libraqm properly in Debian builts.
**What steps did you take to resolve issue yourself before reporting it here**
I tried different versions of php 7.4, php8.0 to php 8.4 on Ubuntu 20.04, Debian 11 and Debian 12 with sury packages and debian original packages, they all had the same issue. On the other hand, I found that remi packages on centos 7 / 8 do not have this issue.
**Expected behavior**
The output of the above code should have a properly connected alphabet like the following output:
![image](https://github.com/oerdnj/deb.sury.org/assets/10244293/ab797d76-548c-423a-8d6f-c6b18951c7e7)
Describe the bug php-gd (and thus libgd3 library on Debian/Ubuntu repos) does not connect Persian/Arabic characters properly. This is while the same sample code provided below shows a properly connected Persian/Arabic characters when running the same version of php and libgd from remi repo.
To Reproduce Steps to reproduce the behavior:
// Create a new image with width and height $width = 200;$height = 50; $image = imagecreatetruecolor($width, $height);
// Allocate colors for text and background $bg_color = imagecolorallocate($image, 255, 255, 255); // white background $text_color = imagecolorallocate($image, 0, 0, 0); // black text
// Fill the background with white imagefilledrectangle($image, 0, 0, $width, $height, $bg_color);
// Add text to the image $text = "سلام"; $font_size = 32;$text_x = 10;$text_y = 30;
// Download the font file $font_url = 'http://themes.googleusercontent.com/static/fonts/lateef/v2/PAsKCgi1qc7XPwvzo_I-DQ.ttf'; $font_file = './Lateef.ttf'; // Destination path for downloaded font file file_put_contents($font_file, file_get_contents($font_url));
// Set font path $font_path = $font_file;
// Add text using TrueType font imagettftext($image, $font_size, 0, $text_x, $text_y, $text_color, $font_path, $text);
// Output the image as JPEG imagejpeg($image);
// Free up memory imagedestroy($image);
// Remove the downloaded font file unlink($font_file); ?>