1

I am trying to print String of Russian Language in image, but it shows nothing, in this example, only 123 english is shown,здрасти is just empty space

$font = "Font.ttf";
                            $string = "здрасти 123 english";
            // I have tried this
                  $string = html_entity_decode($string, ENT_NOQUOTES, 'UTF-8');

                            imagettftext($this->fond,  20, 0, 11, 21, $textcolor, $font, $string)

;

I have tried a lot of stuff but no works... Have you guys any idea?

Mr.Samxo
  • 27
  • 7

1 Answers1

0

You 'have tried a lot of stuff' what stuff then?

did you put charset="utf8" in your <head>?

or put in ISO-8859-5 in your charset, it's for cyrillic

http://htmlbook.ru/html/meta/charset

Or perhaps your font doesn't contain cyrillic characters? Also would be nice to see the complete code.

Thielicious
  • 4,122
  • 2
  • 25
  • 35
  • My generating image link : [link])http://myapps123.com/resimg.php?r=248&u=1227885147241860&f=1721684014739808&fn=Mariam&un=Grigol) in that link, is only PNG so I don't know how to make their Head's for charset. I did header("Content-type: image/png; charset='utf-8'"); And in actually only resimg.php I wrote charset= "utf-8" in heads but no changes – Mr.Samxo Jul 10 '16 at 12:55
  • I've Russian FOnt taken so I think it should wok, help me with this header stuff, I generate only PNG on link that I sent you so how can I write head tags there – Mr.Samxo Jul 10 '16 at 13:00
  • ah, now I know what you mean: could be a possible dublicate of [this](http://stackoverflow.com/questions/198007/php-function-imagettftext-and-unicode) it's been solved there – Thielicious Jul 10 '16 at 13:02
  • I tried : ' $string = "здрасти сссс სსსს ssss 343243"; $text = mb_convert_encoding($string, 'HTML-ENTITIES',"UTF-8"); // Convert HTML entities into ISO-8859-1 $text = html_entity_decode($string,ENT_NOQUOTES, "ISO-8859-1"); // Convert characters > 127 into their hexidecimal equivalents $out = ""; for($i = 0; $i < strlen($text); $i++) { $letter = $text[$i]; $num = ord($letter); if($num>127) { $out .= "$num;"; } else { $out .= $letter; } } ' But nothings shows now, even not English anguage – Mr.Samxo Jul 10 '16 at 13:09
  • And wrote $out in imagettftext instead of $string – Mr.Samxo Jul 10 '16 at 13:11
  • ' $text = "здрасти сссс სსსს ssss 343243"; $text = mb_convert_encoding($text, 'HTML-ENTITIES',"UTF-8"); $text = html_entity_decode($text,ENT_NOQUOTES, "ISO-8859-1"); // Convert characters > 127 into their hexidecimal equivalents $out = ""; for($i = 0; $i < strlen($text); $i++) { $letter = $text[$i]; $num = ord($letter); if($num>127) { $out .= "$num;"; } else { $out .= $letter; } } imagettftext($this->fond, 20, 0, 11, 21, $textcolor, $font, $out);' – Mr.Samxo Jul 10 '16 at 13:15
  • It was problam of TTF that I used , download correct one, on Localhost, it works! But on website, i get Boxes when I type letter only, numbers works – Mr.Samxo Jul 10 '16 at 14:13
  • good to hear. did you put the iso number inside the html entity function? – Thielicious Jul 10 '16 at 15:06
  • It was jutt TTF issue somehow – Mr.Samxo Jul 10 '16 at 22:07