如何在不嵌入的情况下使用 TCPDF 在 PDF 中使用 Arial
我已成功将字体 Arial
添加到 TCPDF
,但是由于嵌入了该字体,文件大小很大。我本以为 Arial
是绝大多数用户机器上的标准字体,所以有没有办法通过使用 Arial
(如果可用)然后使用 Helvetica 来工作
如果没有,那么有任何 sans-serif 字体作为备份吗?
I have successfully added the font Arial
to TCPDF
, however the filesize is large due to it embedding the font. I would have thought Arial
was a standard font on the vast majority of users machines, so is there a way of it working by using Arial
if available, then Helvetica
if not, then any sans-serif font as a backup?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以对字体进行子集化,从而仅嵌入文档中实际使用的字形。这将节省一些空间,因为 Arial 具有用于非常大的 Unicode 字符空间的字形。
它是 setFont() 调用中的最后一个参数(滚动到页面底部)。
You can subset the font, which embeds only the glyphs that are actually used in your document. That'll save some space as Arial has glyphs for a very very large swath of the Unicode character space.
it's the last argument in the setFont() call (scroll to the bottom of the page).
我发现,如果我删除字体文件夹中除以
.php
结尾的文件之外的所有arial
文件,文件大小会下降到 500KB 左右,就像tcpdf。我想这意味着它们现在没有嵌入,如果用户没有 arial,它们将恢复为用户计算机上的另一种无衬线字体。I found that if I remove all
arial
files in the fonts folder other than the ones ending in.php
, the filesize drops to around 500KB, just like the other core fonts in tcpdf. I would imagine that this means they are now not embedded and will revert to another sans-serif font on the users machine if they don't have arial.