github: https://github.com/tecnickcom/TCPDF
将字体复制到TCPDF ools 目录下
打开CMD窗口定位到 vendor ecnickcomTCPDF ools
目录 执行下面的命令
我们以微软雅黑字体为例
php ./tcpdf_addfont.php -b -t TrueTypeUnicode -f 97 -i msyh.ttf
如果成功CMD会出现下面的代码
>>> Converting fonts for TCPDF:
*** Output dir set to C:phpStudyPHPTutorialWWWchuanqivendor cpdf/fonts/
+++ OK : C:phpStudyPHPTutorialWWWchuanqivendor cpdf oolsmsyh.ttf added
as msyh
>>> Process successfully completed!
这时微软雅黑字体就转换完成并复制到TCPDFfonts目录下了
直接设置字体即可
$tcpdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$tcpdf->SetFont('msyh', '', 10, '', true);
如果php不是内部命令
请将php目录加入环境遍量
具体方法请咨询度娘