Many people have asked similar questions. Most of them are advised to use the right fonts. I tried most of the available tamil utf fonts. I haven't found complete solution.
After from fonts, it looks like wee need to swap the text.
கு -> It is a single letter combined from two letters.
க ு -> These are the two letters used to make that single letter.
function str_split_unicode($str, $length = 1) {
$tmp = preg_split('~~u', $str, -1, PREG_SPLIT_NO_EMPTY);
if ($length > 1) {
$chunks = array_chunk($tmp, $length);
foreach ($chunks as $i => $chunk) {
$chunks[$i] = join('', (array) $chunk);
}
$tmp = $chunks;
}
return $tmp;
}
I used the above function to find those two letters.
$text = "கு";//க ு
$text_array = str_split_unicode($text);
print_r($text_array);
Array ( [0] => க [1] => ு )
$font_path = 'TSCu_SaiIndira.ttf';
$image = imagecreatetruecolor(200, 200);
$white = imagecolorallocate($image, 255, 255, 255);
//$sentence = utf8_decode($sentence);
imagettftext($image, 26, 0, 75, 100, $white, $font_path, $text);
// Send Image to Browser
imagejpeg($image,"o.jpg",100);
// Clear Memory
imagedestroy($image);
It didn't work.
$text = $text_array[1].$text_array[0];
Still it didn't work. But i tried this method on some other letters, it worked. For example, it worked on this word. "ஜெ".
The syllable for "ஜெ" is 'A' sound. The syllable for "கு" is 'Uooo' sound.