想在imagefttext函数PHP中显示半个字母,例如“અર્થ” 和“અસત્ય” ,但结果有所不同。像这样。
或者有人可以通过另一种方式帮助我吗?
<?php
header('Content-type: text/html; charset=utf-8');
#Declare fixed values
$textY = 190;
$textX = 130;
$textY2 = 280;
$textX2 = 130;
$textFont = './fonts/notoSans/NotoSansGujarati-Bold.ttf';
// $textFont = './fonts/Shrikhand-Regular.ttf';
$textSize = 54;
$imagesFolder = './images';
$text = "અર્થ";
$text2 = "અસત્ય";
//header("Content-Type: image/png");
header("Content-Type: image/png");
//Creating background image
$im = imagecreatefrompng('https://i.stack.imgur.com/A9Oll.png');
//$im = imagecreatetruecolor(512,512);
// Create the clours to be used.
$yellow = imagecolorallocate( $im, 255, 255, 0 );
imagefttext( $im, $textSize, 0, $textX, $textY, $yellow, $textFont, $text );
imagefttext( $im, $textSize, 0, $textX2, $textY2, $yellow, $textFont, $text2 );
$imageFile = $imagesFolder.'/'.rand(0,500).'.png';
imagepng( $im, $imageFile );
// Unload resources.
imagedestroy( $im );
?>
=> 编辑0.1: 问题是在图像中显示半角字母。 -我需要的输出(我在photoshop中完成了):desired Output image -但是我正在看这段代码:image getting from code
答案 0 :(得分:0)
使用Unicode不可能看起来像这样,并且长期以来一直是一个问题。来自10 year old bug上的PHP开发人员:
谢谢,现在我明白了。这个问题与以下问题无关 孟加拉语,但通常是组合字符,这些字符是 imagettftext()不支持。
我尝试使用Imagick扩展名进行此操作,但输出相同。
一种可能的解决方法是找到使用另一种编码(例如ISCII)的字体,然后使用mb_convert_encoding()
或类似函数将文本转换为该编码。
或者让命令行工具生成的图像与exec()
一起运行。