php – 在imagettftext()中使用马拉雅拉姆语单词

我试图使用php imagettftext()函数将马拉雅拉姆语(印度语)单词转换为图像.我也在使用Malayalam字体.这是我正在使用的代码块.

// malayalam word
$utf8str = "കറുപ്പ്";

// buffer output in case there are errors
ob_start();

// create blank image
$im = imagecreatetruecolor(400,40);
$white = imagecolorallocate($im,255,255,255);
imagefilledrectangle($im,0,0,imagesx($im),imagesy($im),$white);

// write the text to image
$font = "anjali.ttf";
$color = imagecolorallocatealpha($im, 50, 50, 50, 0); // dark gray
$size = 20;
$angle = 0;
$x = 5;
$y = 25;
imagettftext($im, $size, $angle, $x, $y , $color, $font, $utf8str);

// display the image, if no errors
$err = ob_get_clean();
if( !$err ) {
    header("Content-type: image/png");
    imagepng($im);
}

使用此代码,我得到以下输出

《php – 在imagettftext()中使用马拉雅拉姆语单词》

我已经尝试了很多来自stackoverflow的Malayalam字体和代码.任何人都可以帮我吗?

最佳答案 经过长时间的研究,我发现现有的马拉雅拉姆字体并不支持所有字符.我们将不得不等待支持所有角色的新字体出现.

点赞