在 tcpdf 中显示泰卢固语 unicode 字体是否需要任何配置? [英] Is there any configurations required to show telugu unicode fonts in tcpdf?
问题描述
我必须从 php 页面生成一个包含 html 的 PDF,其中包括 unicode 字体(泰卢固语).当我打印 html 代码并使用 TCPDF 渲染为 PDF 时,它的显示效果很好,Unicode 字符会扭曲字母格式.
I have to generate a PDF from php page contains html which includes unicode fonts (Telugu). Its showing perfectly when I print html code and while rendering to PDF using TCPDF, the unicode characters are distorting of letter formations.
我已经从谷歌翻译器复制了泰卢固语字体并将泰卢固语字体添加到 tcpdf 库中.
I have copied the telugu font from google translators and added a telugu font into tcpdf lib.
$message = '<h2 align="center">ధన్యవాదములు -- శుభోదయం</h2>';
$fontname = $pdf->addTTFfont('E:\xampp\htdocs\ncs\svdn\flowers\tcpdf\fonts\mandali-regular.ttf', 'TrueTypeUnicode');
$pdf->SetFont($fontname, "",30, false);
$pdf->writeHTML($message, true, 0, true, 0);
$pdf->Output("Test.pdf", 'I');
html 中的输出如下所示.同样也必须以 PDF 格式打印.
The output in html is like below. And the same has to be printed in PDF too.
ధన్యవాదములు -- శుభోదయం
但在本期中,上述辅音是脱节的:
But in current issue, the above consonants are disjointed:
推荐答案
TCPD 不支持印度语脚本工作所需的 OpenType 布局功能.
TCPDF doesn't support the OpenType layout features needed for Indic scripts to work.
mPDF 支持多种印度语脚本——特别是泰卢固语——然而,所以如果您在项目中不太愿意切换,那将是我的建议.
mPDF supports several indic scripts - including Telugu specifically - however, so if you're not too far along in your project to switch, that would be my recommendation.
例如,在安装 带有作曲家的 mPDF:
include 'vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf();
//I'm being a little lazy here and letting mPDF select the appropriate
//appropriate font.
$mpdf->autoScriptToLang = true;
$mpdf->baseScript = 1; // Use values in classes/ucdn.php 1 = LATIN
$mpdf->autoLangToFont = true;
$mpdf->WriteHTML('<h2 style="text-align: center;">'.
'ధన్యవాదములు -- శుభోదయం</h2>');
$mpdf->Output('test_mpdf_lang.pdf');
这篇关于在 tcpdf 中显示泰卢固语 unicode 字体是否需要任何配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!