Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在GD中显示从右向左连接的语言(如波斯语和阿拉伯语)-可能是PHP错误_Php_Gd - Fatal编程技术网

在GD中显示从右向左连接的语言(如波斯语和阿拉伯语)-可能是PHP错误

在GD中显示从右向左连接的语言(如波斯语和阿拉伯语)-可能是PHP错误,php,gd,Php,Gd,我想用php gd库创建一个带有文本的图像 一切正常,但当我尝试使用imagefttext()从右向左连接的语言(如波斯语)编写单词时,我的文本从左向右(反向)呈现,字符不再连接 连接字符的示例:ماه 未连接字符的示例:ماه 这是我的密码: header('Content-Type: image/jpeg'); $thumb_path = "..."; $font_path = "..." $img = imagecreatefromjpeg($thumb_p

我想用php gd库创建一个带有文本的图像

一切正常,但当我尝试使用
imagefttext()
从右向左连接的语言(如波斯语)编写单词时,我的文本从左向右(反向)呈现,字符不再连接

连接字符的示例:ماه 未连接字符的示例:ماه

这是我的密码:

    header('Content-Type: image/jpeg');
    $thumb_path = "...";
    $font_path = "..."
    $img = imagecreatefromjpeg($thumb_path);
    $color = "...";
    // __month is a Persian word :  ( م ا ه -->  ماه )
    $text = $months." ".__month;
    imagefttext($img,29, 10, 230, 135, $color, $font_path, $text); // <--
    imagejpeg($img);
结果是一样的

有一些可用的库可能可以解决这个问题。我知道你们中的大多数人不熟悉波斯语阿拉伯语语言,但我的问题是为什么
gd
不支持从右向左的本地连接语言


这可能是gd库中的错误吗?

您是否正确设置了区域设置

从包装上看,波斯语应该是波斯语-
fa_IR.UTF-8
fa_utf8。不要忘了检查它是否设置正确:

$rv = setlocale(LC_ALL, "fa_IR.UTF-8");
var_dump($rv);
编辑:尝试过,但似乎也没有任何帮助。

似乎没有任何帮助(设置正确的区域设置),本机PHP支持存在缺陷,这可能就是创建第三方软件包的原因:

使用 作为一种魅力:

只需将库复制到PHP目录(不必是管理员)。用法很简单:

// init:
include('php-gd-farsi-master/FarsiGD.php');
$gd = new FarsiGD();

....
// then convert your text:
$tx = $gd->persianText($str, 'fa', 'normal');
您甚至不必设置正确的区域设置!:-)

整个示例代码:

<?php

include('php-gd-farsi-master/FarsiGD.php');

$gd = new FarsiGD();

// Create a 300x100 image
$im = imagecreatetruecolor(300, 100);
$red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);

// Make the background red
imagefilledrectangle($im, 0, 0, 299, 99, $red);

// Path to our ttf font file
//$font_file = './Vera.ttf';
$font_file = './cour.ttf';

// Draw the text 'PHP Manual' using font size 13
$text = imagecreatetruecolor(200, 60);
imagefilledrectangle($text, 0, 0, 200, 60, $red);
$str = '**ماه**';
$tx = $gd->persianText($str, 'fa', 'normal');
imagefttext($text, 24, 10, 10, 50, $black, $font_file,$tx );
$im = $text;

// Output image to the browser
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
?>


看看这里,嗯,这是一个错误吗?检查一下,这个人也有同样的问题,并且说这个错误不会被解决,这里有一些链接可以获取更多信息。也许你应该显示你所期望的准确图像。这个问题不清楚。链接的bugreport中附带的图片也不起作用。图片的文本应该是很好的完整答案,谢谢,它解决了我的问题,但你不认为这个bug应该被修复吗?@AlirezaFallah是的,绝对应该!这个包裹不需要!谢谢你,伙计,恭喜你成为了15k;)谢谢@AlirezaFallah:-)还没有,还缺41分:-)PS:这是我第一次排版这些东方字符。酷:-)我把这个包裹放在Wamp上了。但不能运行它。它在FarsiGD.php中返回许多“Undefined variabl”错误
<?php

include('php-gd-farsi-master/FarsiGD.php');

$gd = new FarsiGD();

// Create a 300x100 image
$im = imagecreatetruecolor(300, 100);
$red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);

// Make the background red
imagefilledrectangle($im, 0, 0, 299, 99, $red);

// Path to our ttf font file
//$font_file = './Vera.ttf';
$font_file = './cour.ttf';

// Draw the text 'PHP Manual' using font size 13
$text = imagecreatetruecolor(200, 60);
imagefilledrectangle($text, 0, 0, 200, 60, $red);
$str = '**ماه**';
$tx = $gd->persianText($str, 'fa', 'normal');
imagefttext($text, 24, 10, 10, 50, $black, $font_file,$tx );
$im = $text;

// Output image to the browser
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
?>