“Font_Glyph_Outline”在DOMPDF中使用WebFonts时出错 [英] "Font_Glyph_Outline" Error when using WebFonts with DOMPDF

查看:191
本文介绍了“Font_Glyph_Outline”在DOMPDF中使用WebFonts时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图实现DOMPDF,一切工作(感谢多个Stack用户),但我现在无法呈现WebFonts时。

I'm trying to implement DOMPDF, everything is working (thanks to multiple Stack users) but I'm now having trouble rendering WebFonts when.

根据Google DO代码项目中的示例DOMPDF可以使用webfonts:
http://pxd.me/dompdf/www/examples.php#css_at_font_face.html,html

According to the examples on the Google Code project for DOMPDF it is possible to use webfonts: http://pxd.me/dompdf/www/examples.php#css_at_font_face.html,html

我已参照字体在页面中,我将是一个HTML页面:

I've ref'd the font in the page as I would a HTML page:

<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:400,700,300' rel='stylesheet' type='text/css'>

我已在CSS中引用字体:

and I've ref'd the font in the CSS:

body{
    font-family: 'Roboto Condensed', sans-serif;
}

但DOM PDF报告:

but DOM PDF reports:

Class 'Font_Glyph_Outline' not found

更多DOMPDF大师来帮助我?

Can any more DOMPDF guru's come to my aid?

推荐答案

有两个问题需要在你的问题中解决。更加紧迫的是PHP错误,正如@ tom-metcalfe指出,尚未解决。可帮助解决的两个信息是:dompdf版本,PHP版本。

There are two issues that need to be addressed in your question. The more pressing is the PHP error which, as @tom-metcalfe pointed out, has yet to be resolved. The two pieces of information that may help resolve that are: dompdf version, PHP version.

如果您确实解决了此错误,您需要解决另一个问题: dompdf只理解at-font CSS中的命名字体权重。如果你可以自己维护CSS,你可以解决这个问题。

If you do resolve that error you'll need to address another issue: dompdf only understands named font weights in the at-font CSS. If you're OK maintaining the CSS yourself you can work around this issue.

你需要工作基于真正的类型字体(TTF)版本的CSS,因为dompdf目前只能嵌入TTF。 Google网络字体字体服务提供了基于访问浏览器的最合适的格式。要获取样式表的TTF版本访问在需要TTF网络字体的浏览器中的网址。我在我的服务器上使用lynx(TTF必须是未知浏览器的后备)。使用Google的样式表创建自定义CSS,例如:

You need to work based off the True Type Font (TTF) version of the CSS since dompdf can currently only embed TTF. The Google Web Fonts at-font service offers up the most appropriate format based on the visiting browser. To get the TTF version of the stylesheet visit the URL in a browser that requires TTF for web fonts. I used lynx on my server (TTF must be the fallback for unknown browsers). Use the stylesheet from Google to create your customized CSS, e.g.:

@font-face {
  font-family: 'Roboto Condensed Light';
  font-style: normal;
  font-weight: normal;
  src: local('Roboto Condensed Light'), local('RobotoCondensed-Light'), url(http://themes.googleusercontent.com/static/fonts/robotocondensed/v7/b9QBgL0iMZfDSpmcXcE8nL3QFSXBldIn45k5A7iXhnc.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto Condensed';
  font-style: normal;
  font-weight: normal;
  src: local('Roboto Condensed Regular'), local('RobotoCondensed-Regular'), url(http://themes.googleusercontent.com/static/fonts/robotocondensed/v7/Zd2E9abXLFGSr9G3YK2MsDR-eWpsHSw83BRsAQElGgc.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto Condensed';
  font-style: normal;
  font-weight: bold;
  src: local('Roboto Condensed Bold'), local('RobotoCondensed-Bold'), url(http://themes.googleusercontent.com/static/fonts/robotocondensed/v7/b9QBgL0iMZfDSpmcXcE8nDokq8qT6AIiNJ07Vf_NrVA.ttf) format('truetype');
}

注意 font-weight 声明被修改为使用命名的权重,字体的轻变体被赋予自己的姓氏。因为dompdf没有完全支持数字权重,你必须这样做。

Notice that the font-weight declarations were modified to use the named weights and that the "light" variant of the font is given its own family name. Since dompdf doesn't have full support of numeric weights you'll have to do it this way.

我不知道这些字体网址是多么稳定。它们似乎是某种哈希,所以它们可能会在某个时候发布新版本。为了安全起见,您可以自行托管文件。

I don't know how stable these font URLs are. They appear to be some kind of hash so it's possible they may go away at some point when a new version is released. To be safe you may want to host the files yourself.

这篇关于“Font_Glyph_Outline”在DOMPDF中使用WebFonts时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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