2

我尝试使用 PHP 在图像中编写阿拉伯文本。这是我的代码:

<?php

header("Content-Type: image/png; charset=utf8");
$im = imagecreatetruecolor(150, 30);

// Create some colors
$white = imagecolorallocate($im, 100, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

$font = 'tahoma.ttf';
$t = strrev('إن الدين عند الله الإسلام');
$text=utf8_encode($t);
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagepng($im);
imagedestroy($im);
?>

谢谢你。

4

2 回答 2

3

输出是什么?

strrev 函数与 unicode 不兼容 http://de2.php.net/manual/en/function.strrev.php 有关 unicode 兼容的示例,请参阅那里的注释。

另请参阅 imagettftext 页面,我认为以下评论正是您所需要的: http: //de2.php.net/manual/en/function.imagettftext.php#97767

于 2010-09-13T09:51:17.333 回答
0

这将为您工作:

  1. 包括(“fagd.php”);
  2. 使用 imagettftext($im, 20, 0, 10, 20, $black, $font, fagd($text));

fagd.php 代码在这里:

http://cdn.shirazitco.ir/fagd.txt

于 2011-04-06T07:04:52.497 回答