If I want to write the following text on the image:
दीक्षा शिक्षा क्या क्या हो गया!
Then it does not not give the expected result but instead is printing out text on the picture as below. I have tried almost all the devanagari ttf and unicode fonts available for Hindi.
Here is the code:
$quote="दीक्षा शिक्षा क्या क्या हो गया!";
imagettftext($new_pic, $fontsize, 0, 170, 155-$hidd/2, $color, $font, $quote);
Any help will be very much appreciated.
I am not well versed in Hindi but I think the GD library you are using is not using the rules about Hindi language that changes the order in which glyphs are displayed. I don't know what these rules are, but guess they are encoded in the font's GSUB or GPOS tables. GSUB controls the way sequences of glyphs are displayed and GPOS controls the spacing of glyphs. I assume GD library does not process the GPOS or GSUB tables, which is why the order of your string in imagettfext is the order of the glyphs in the string. You may need to implement some string munging code in your script that takes strings, and orders the characters correctly knowing that GD Library will display them in the order they are in the string.
Please use the code below for the following hindi rule
I have used C# in the above code you can convert it to your scripting language. Similarly you can include more rules in the code so that you get the desired text in the GD library. Hope this solves your problem.