vendredi 22 juillet 2016

Using Malayalam language word in imagettftext()

I am trying to convert Malayalam(Indian language) words to image using php imagettftext() function. I am using Malayalam font as well. Here is a block of code I am using.

// 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);
}

With this code, I get the following output

enter image description here

I have tried many Malayalam fonts and codes from stackoverflow. Can anybody help me with this?

Aucun commentaire:

Enregistrer un commentaire