如何在 TCPDF 中实现自定义字体 [英] How to implement custom fonts in TCPDF
本文介绍了如何在 TCPDF 中实现自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 TCPDF 中,只有几种字体可供选择,以创建 pdf 文件.我想将 Tahoma
设置为我的 pdf 字体.如何在 TCPDF 中包含 Tahoma
?
In TCPDF, there are only a few fonts to choose from, to create pdf files. I want to set Tahoma
as my pdf font. How can I include Tahoma
in TCPDF??
推荐答案
最新的 TCPDF 版本使用 addTTFfont() 方法自动将字体转换为 TCPDF 格式.例如:
The latest TCPDF version automatically convert fonts into TCPDF format using the addTTFfont() method. For example:
// convert TTF font to TCPDF format and store it on the fonts folder
$fontname = TCPDF_FONTS::addTTFfont('/path-to-font/FreeSerifItalic.ttf', 'TrueTypeUnicode', '', 96);
// use the font
$pdf->SetFont($fontname, '', 14, '', false);
有关更多信息和示例,请查看 TCPD 字体文档页面.
For further information and examples, please check the TCPDF Fonts documentation page.
注意:转换字体后,TCPDF 不再需要 TTF 文件或上述对 addTTFfont()
的调用!
NOTE: Once the font has been converted, TCPDF no longer requires the TTF file or the above call to addTTFfont()
!
这篇关于如何在 TCPDF 中实现自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文