I am trying to add overlay text to images using the GD library in php, while it works perfectly for characters in english, I am having rendering issues when the text is in hindi, even when the font used supports hindi text. Upon transformation and rendering on the image using the font, the result is not as desired.
I am using the font downloaded from here RozhaOne
This is the code which I am executing
function createImageWithText()
{
$image = imagecreatefromjpeg($this->asset_url.'/images/input.jpeg');
$fontSize = 32;
list($r, $g, $b) = sscanf("#00bfff", "#%02x%02x%02x");
$fontColor = imagecolorallocate($image, $r, $g, $b);
$font = $this->asset_url.'/fonts/RozhaOne-Regular.ttf';
$text = "कृति";
imagettftext(
$image,
$fontSize,
0,
500,
500,
$fontColor,
$font,
$text
);
$save_path = $this->asset_url.'/images/output.png';
imagepng($image, $save_path);
imagedestroy($image);
}
I have tried the solution suggested here and here but it did not work when I am using the font specified or other hindi supported fonts.
This seems to be an issue with the GD library (Using php 7.4) handling hindi font, would be great to get some insights on how this can be solved/supported.

