imagettftext и кириллица
Пытаюсь ввести кириллицу, но буквы не записываются как надо, хотя шрифт поддерживает кириллицу. Когда убираю с
imagettftext ( $im, 20 ,0 ,$x,$y ,$color2 ,$font,$text );
Всё работает
imagettftext ( $im, 20 ,0 ,$x,$y ,$color2 ,$font,$text[$j]);
Уже проблемы. Подскажите, как сохранить $text[$j] и чтоб кириллица корректно отображалась
<?php
$text = $_POST['text'];
$imx = 1000;
$imy = 1000;
$im = imageCreate($imx, $imy);
$color = imageColorAllocate($im, 255, 255, 255);
imagefilledrectangle($im ,$imx, $imy, $color);
$color2 = imageColorAllocate($im, 0, 0, 0);
$font = getcwd()."/19081.ttf";
echo $font;
//imagestring($im, 5, 10,10,$text, $color2);
$j = 0;
$y = 40;
$x = 50;
$s = 0;
for ($i=0; $i < strlen($text)*15; $i+=15) {
$s+=imagefontwidth(3)+8;
$x=$s;
if ($x > $imx-50) {
$y += 20;
$x = 50;
$s = 0;
}
imagettftext ( $im,
20 ,
0 ,
$x,
$y ,
$color2 ,
$font ,
$text[$j]
);
$j++;
}
$name = 'img/'."hanler.jpg";
$imgenter = imageJpeg($im, $name);
echo "<img src='$name' width='100'>";
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form action=" " method="post">
<input type="text" name="text"><br>
<input type="submit">
</form>
</body>
</html>