我正面临着使用TCPDF库在php中生成pdf的问题。我需要正确显示孟加拉字体。我尝试添加一些孟加拉字体(即SolaimanLipi.ttf,SutonnyOMJ.ttf,Siyamrupali.ttf,Nikosh.ttf等)。我可以在pdf上看到孟加拉字体,但字体显示不正确。它放错了这个词。孟加拉(Unicode)字体在tcpdf中无法正确呈现
通过添加这种字体,我看到在/ fonts /目录下成功创建了3个文件“solaimanlipi.ctg.z”,“solaimanlipi.php”和“solaimanlipi.z”。以及我可以在PDF上看到孟加拉字体,但是这种字体错位/分散。我附上我实际看到的照片。
这里是显示上述结果的代码:
<?php
$strData = file_get_contents('./data3.txt');
?>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<style>
@font-face
{
font-family: myUniFont;
src: url(./SolaimanLipi_22-02-2012.ttf);
}
</style>
</head>
<body>
<span style="font-family: myUniFont;"><?php echo $strData; ?></span>
</body>
</html>
我用下面的代码来使用同样的字体,我PDF:
$strBNFont = TCPDF_FONTS::addTTFfont('./SolaimanLipi_22-02-2012.ttf', 'TrueTypeUnicode', '', 32);
$pdf->SetFont($strBNFont, '', 8, '', 'false');
,它是怎么看起来像PDF::(
编辑#1
哇! (OMG
亲爱的主席先生,问题不就PDF/TCPDF库甚至也不是在字体文件,它自
请检查下面的PHP代码:
<?php
header('Content-type: image/png');
$text = 'তোমাদের জন্য মুক্তিযুদ্ধের গল্প';
$font = './Fonts/SolaimanLipi_22-02-2012.ttf';
$im = imagecreatetruecolor(600, 300);
$bg_color = imagecolorallocate($im, 255, 255, 255);
$font_color = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 599, 299, $bg_color);
imagettftext($im, 20, 0, 10, 50, $font_color, $font, $font);
imagettftext($im, 20, 0, 10, 120, $font_color, $font, $text);
imagepng($im);
imagedestroy($im);
?>
这究竟是怎么出口! /渲染浏览器的PNG图像:
当我尝试使用imagettftext功能它也打破了C到打印图像文件中的文本字符:(
因为我相信它不是字体问题,因为我刚刚测试过60 +字体和所有破碎..浏览器(HTML代码)显示他们非常正确。
所以,我的东西,这是非常大于我的大脑可以容纳/处理;(
所以,像你这样的专家可能会唯一出路再次:)
感谢您的时间
hello有什么帮助吗? –
没有人熟悉tcPDF unicode问题? –
我非常困难,真的需要一些帮助... –