我正在尝试使用TFPDF以PDF格式显示泰米尔语内容。我已经下载了TSCu_SaiIndira.ttf,一种泰米尔字体,并将其存储在path C:\wamp\www\tfpdf\font\unifont中。存储在记事本中的泰米尔语单词是'பெயர்கள்‘。当我运行下面的代码时,它打印出不同的字母
<?php
require('tfpdf.php');
$pdf = new tFPDF();
$pdf->AddPage();
// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','TSCu_SaiIndira.ttf',true);
$pdf->SetFont('DejaVu','',14);
// Load a UTF-8 string from a file and print it
$txt = file_get_contents('HelloWorld.txt');
$pdf->Write(8,$txt);
// Select a standard font (uses windows-1252)
$pdf->SetFont('Arial','',14);
$pdf->Ln(10);
$pdf->Write(5,'The file size of this PDF is only 12 KB.');
$pdf->Output();
?>我是个编程新手。我已经阅读了所有张贴的相关问题的答案,但都没有结果。
发布于 2017-10-08 00:09:32
在此代码中:
$pdf->AddFont('DejaVu','','TSCu_SaiIndira.ttf',true);
$pdf->SetFont('DejaVu','',14);您正在使用'DejaVu‘作为字体系列名称,这是不正确的。我做了一个快速测试,然后:
$pdf->AddFont('TSCu_SaiIndira','','TSCu_SaiIndira.ttf', true);
$pdf->SetFont('TSCu_SaiIndira','',14);对我很管用。
https://stackoverflow.com/questions/46622138
复制相似问题