如何在TCPDF中实现自定义字体 [英] How to implement custom fonts in TCPDF

查看:269
本文介绍了如何在TCPDF中实现自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在TCPDF中,只有几种字体可供选择,以创建PDF文件。我想设置 Tahoma 作为我的pdf字体。如何在TCPDF中包含 Tahoma ??

解决方案

最新的TCPDF版本使用addTTFfont()方法自动将字体转换为TCPDF格式。例如:
$ b

  //将TTF字体转换为TCPDF格式并将其存储在字体文件夹中
$ fontname = TCPDF_FONTS :: addTTFfont('/ path-to-font / FreeSerifItalic.ttf','TrueTypeUnicode','',96);

//使用字体
$ pdf-> SetFont($ fontname,'',14,'',false);

有关更多信息和示例,请查看 TCPDF字体文档页面
$ b 注意:字体转换后,TCPDF不再需要TTF文件或上述调用 addTTFfont()


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??

解决方案

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);

For further information and examples, please check the TCPDF Fonts documentation page.

NOTE: Once the font has been converted, TCPDF no longer requires the TTF file or the above call to addTTFfont()!

这篇关于如何在TCPDF中实现自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆