;'); $this->_out('endobj'); //Font descriptor $this->_newobj(); $this->_out('<</Type /FontDescriptor'); $this->_out('/FontName /'.$font['name']); $this->_out('/Flags 6'); $this->_out('/FontBBox [0 0 1000 1000]'); $this->_out('/ItalicAngle 0'); $this->_out('/Ascent 1000'); $this->_out('/Descent 0'); $this->_out('/CapHeight 1000'); $this->_out('/StemV 10'); $this->_out('>>'); $this->_out('endobj'); } } ?>
将以上代码存为chinese.php即可引用。但用它只能得到一种字体。为了支持所有中文字体,可用ttf2pt1程序将TrueType字体转化pt1字体,一个一个地转(具体方法在FPDF的教程中有详细说明)。为了支持其他中文字体,养分要修改上面的chinese.php,如下:
1: Replace the following line in the AddGBFont() method:
function AddGBFont($family='GB',$name='STSongStd-Light-Acro') { $cw=$GLOBALS['GB_widths']; // $name='STSongStd-Light-Acro'; $CMap='GBKp-EUC-H'; ........
2: This is a Sample.
<?php require('chinese.php');
$pdf=new PDF_Chinese(); $pdf->AddGBFont('simsun','宋体'); $pdf->AddGBFont('simhei','黑体'); $pdf->AddGBFont('simkai','楷体_GB2312'); $pdf->AddGBFont('sinfang','仿宋_GB2312''); $pdf->Open(); $pdf->AddPage(); $pdf->SetFont('simsun','',20); $pdf->Write(10,'简体中文汉字‘); $pdf->SetFont('simhei','',20); $pdf->Write(10,'简体中文汉字’); $pdf->SetFont('simkai','',20); $pdf->Write(10,'简体中文汉字‘); $pdf->SetFont('sinfang','',20); $pdf->Write(10,'简体中文汉字’); $pdf->Output(); ?>
上一页 [1] [2] [3] [4] [5] [6] [7] [8] |