I'm using Intervention library to write overlay text on an image. This works perfect if the text provided is of one language(say English)
I need to write overlay text in multiple languages depending on the input given(the input can be in any language).
Here is my code base for generating the above.
public static function generateTextOverImage($image, $text)
{
$img = Image::make($image->getContent());
$extension = 'jpg';
$centerX = 25;
$centerY = 210;
$text = str_replace('<br>', "\n", html_entity_decode($message)) ;
$lines = explode("\n", wordwrap($text, 21));
$currentLineVIndex = $centerY;
foreach ($lines as $line) {
$img->text($line, $centerX, $currentLineVIndex, function ($font) use ($fontSize) {
$font->file(public_path('fonts/LucidaGrande.ttf'));
$font->size(18);
$font->color('#fdf6e3');
});
}
$encoded = $img->encode($extension);
return $encoded;
}
As the text can be in different languages(One or more language at a time). The expected text over image in broken. It works fine for english language only.
Any help will be highly appreciated. Thanks
Update
is there any font which support multiple languages?