开发者

TCPDF font conversion results in missing glyphs

开发者 https://www.devze.com 2023-03-20 23:50 出处:网络
I\'m using the TCPDF library to generate server-side PDFs daily in a cronjob. This library takes UTF8 strings from the DB and writes them into a PDF using the Arial Unicode MS font (also embedd开发者_

I'm using the TCPDF library to generate server-side PDFs daily in a cronjob. This library takes UTF8 strings from the DB and writes them into a PDF using the Arial Unicode MS font (also embedd开发者_运维百科ing it in the PDF).

To be able to use this font, I had to convert it to a PHP-friendly format following these instructions: http://www.tcpdf.org/fonts.php

However, while most of the languages seem right (glyphs are correct in Hebrew, Chinese, Japanese, Portuguese, etc.), Korean glyphs appear as squared boxes in the PDF.

I noticed many (hundreds of) errors while running the ttf2ufm binary described in the link above:

Previous entry type: M
Warning: **** closepath on empty path in glyph "_d_8235" ****

I'm suspecting this has to do with this issue (not being able to correctly convert those couple of hundred glyphs, thus resulting in an invalid font file).

Am I doing something wrong? Or is this just a limitation of this library?


The latest TCPDF version automatically convert fonts into TCPDF format using the addTTFfont() method. The old font programs and scripts were removed.

For example:

// convert TTF font to TCPDF format and store it on the fonts folder
$fontname = $pdf->addTTFfont('/path-to-font/FreeSerifItalic.ttf', 'TrueTypeUnicode', '', 96);

// use the font
$pdf->SetFont($fontname, '', 14, '', false);
0

精彩评论

暂无评论...
验证码 换一张
取 消