【插件】TCPDF 添加新字体

github: https://github.com/tecnickcom/TCPDF

将字体复制到TCPDF\tools 目录下

打开CMD窗口定位到 vendor\tecnickcom\TCPDF\tools 目录 执行下面的命令

我们以微软雅黑字体为例

 php ./tcpdf_addfont.php -b -t TrueTypeUnicode -f 97 -i msyh.ttf

如果成功CMD会出现下面的代码

>>> Converting fonts for TCPDF:
*** Output dir set to C:\phpStudy\PHPTutorial\WWW\chuanqi\vendor\tcpdf/fonts/
+++ OK   : C:\phpStudy\PHPTutorial\WWW\chuanqi\vendor\tcpdf\tools\msyh.ttf added
 as msyh
>>> Process successfully completed!

这时微软雅黑字体就转换完成并复制到TCPDF\fonts目录下了

直接设置字体即可

 $tcpdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
 $tcpdf->SetFont('msyh', '', 10, '', true);

如果php不是内部命令
请将php目录加入环境遍量
具体方法请咨询度娘

posted @ 2020-11-27 13:32  依然范儿特西  阅读(338)  评论(0编辑  收藏  举报