views:

45

answers:

1

hi , all

I tried to write Arabic text in image with php ..

this is my code ..

 <?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);
?>

thank you for helping me ^_*

+2  A: 

What’s the output?

The strrev function is not unicode compatible http://de2.php.net/manual/en/function.strrev.php See the comments there for examples of unicode compatible ones.

Also see the imagettftext page, I think the following comment is exactly what you need: http://de2.php.net/manual/en/function.imagettftext.php#97767

Kissaki
the output is text but not arabic ..
AboSami
With your original code? Did you try / read the links I posted?
Kissaki