Setting a custom TTF Font in mPDF

2019-07-27 16:20发布

i installed mPDF 6.0 via zip file (not composer), put a font into the ttfonts folder and added the file in config_fonts.php like this:

"eurostyle" => array(   /* Custom */
    'R' => "eurostyle-normal.ttf"
    )

Now i tried adding the font to my mPDF object like this:

$mpdf = new mPDF('c', 'A4-L');
$mpdf -> SetFont('eurostyle');

but nothing changes. There is no error message, the output PDF simpy stays the same.

Does anybody know why?

1条回答
迷人小祖宗
2楼-- · 2019-07-27 16:51

Create your mPDF object without c as mode parameter. Use an empty string or eg. UTF-8.

$mpdf = new mPDF('', 'A4-L');

c mode means the PDF will only use core PDF fonts - therefore it will not use any custom external fonts.

See also the Fonts & Languages/Choosing a configuration page of the manual.

查看更多
登录 后发表回答