印地语文字到图片 - 单词格式不正确PHP

时间:2015-10-15 11:12:57

标签: php

我想在图像上显示印地语单词。这是它的代码,它工作正常,但它没有正确显示“chote E ki matra”。示例“अबहिन्दी”显示为:http://prntscr.com/8rj8mq

此外hindi.txt文件包含以下内容:
अबहिन्दी
मेटाइप
करनाबहुतआसानहै

在php脚本下面随机读取一行并将其放在图像上并显示它。有人可以帮我纠正这个....

<?php

$word= file("hindi.txt");
$random = rand(0,2);
$text = $word[$random];

header('Content-Type: image/png');

// Create the image
$im = imagecreatetruecolor(400, 30);

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

// The text to draw

// Replace path by your own font path
$font = 'Mangal.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);


?>

0 个答案:

没有答案