I want to create an image with a text on it with php gd library.
everything is fine, but when I try to write a word from a right to left connected language (like Persian ) using imagefttext()
, my text is rendering from left to right (inverse) and the chars are not connected any more .
example of connected chars : ماه example of not connected chars : م ا ه
Here is my code :
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);
The rendered image :
I know my problem is not encoding.because I already tried this :
$text = mb_convert_encoding($text, "HTML-ENTITIES", "UTF-8");
And the result is the same.
there are some library available that maybe can solve this problem. and I know that most of you are not familiar with Persian or Arabic languages, but my question is why gd
does not support right to left connected languages natively ?
could this be a bug in gd library ?