mb_language('uni');
mb_internal_encoding('UTF-8');
header('Content-type: image/jpeg');
$our_image = imagecreatefromjpeg('certificates/main.jpg');
$black_color = imagecolorallocate($our_image, 0, 0, 0);
$font_path = 'arial.ttf';
$text = 'সৌরভ দাস';
$text = mb_convert_encoding($text, 'HTML-ENTITIES',"UTF-8");
$text = html_entity_decode($text,ENT_NOQUOTES, "ISO-8859-1");
$font_size=50;
$angle=0;
$left=1500;
$top=1400;
$output = imagettftext($our_image, $font_size,$angle,$left,$top, $black_color, $font_path, $text);
$imgName = "BDCH-Certificate-maper-".$uid.".jpg";
imagejpeg($our_image, 'certificates/'.$imgName);
输出总是显示如下所示。
此外,我尝试了这些字体,SolaimanLipi_29-05-06.ttf,Rajon_Shoily.ttf和kalpurush ANSI.ttf。有人能帮我解决这个问题吗?提前谢谢。
发布于 2020-05-09 15:19:53
不要使用任何编码/解码函数。不需要mb函数。
是否需要转换为.jpg?为什么不简单地输出文本呢?
发布于 2022-06-16 01:04:48
将文本转换为Unicode2Bijoy,您现在只能使用ANSI字体
<?php
header('Content-Type: image/jpg');
require 'Unicode2Bijoy.php'; // https://github.com/mirazmac/Unicode2Bijoy
use mirazmac\Unicode2Bijoy;
$im = imagecreatetruecolor(1920, 1080);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 1919, 1079, $white);
$text = Unicode2Bijoy::convert('সে তার সময় বন্ধুদের সাথে ভালোই কাটাছিলো।');
$font = 'fonts/Li Sheikh Hasina ANSI V2.ttf';
imagettftext($im, 20, 0, 100, 200, $black, $font, $text);
imagejpeg($im);
imagedestroy($im);
?>
সেতারসময়বন্ধুদেরসাথেভালোইকাটাছিলো।
欲了解更多信息:https://github.com/mirazmac/Unicode2Bijoy
ANSI字体:https://lipighor.com
https://stackoverflow.com/questions/61695875
复制相似问题