我有一个具有此配置的服务器:
操作系统:CentOSLinux 7.9.2009
PHP:7.0.27
GD:2.8.3
我有一个简单的脚本将波斯语文本转换为图像:
<?php
header('Content-Type: image/jpeg');
$img = imagecreatetruecolor(100, 100);
$background_color = imagecolorallocate($img, 0, 0, 0);
$text_color = imagecolorallocate($img, 255, 255, 255);
imagettftext($img, 20, 0, 25, 25, $text_color, '/home/font/arial.ttf', 'سلام');
imagejpeg($img);
该代码多年来在服务器上正常运行! 我使用此配置获得新服务器:
操作系统:DebianLinux 12
PHP:8.2.7
GD:2.8.3
但是脚本没有正确的结果并且字符单独打印!
我不想使用一些基于替换字符的解决方案(如this),我需要一个主要解决方案来解决脚本像旧的CentOS服务器一样执行的问题。必须检查/安装哪个模块/包?
(我也尝试
apt-get install php-gd php-intl php-mbstring -y
)
为了解决这个问题,我们需要使用
"Support for complex text: enabled"
选项来编译 GD。
或者使用带有该选项的 GD 编译版本。