javascript - 为什么 Material Icons 不在 phantom js 中呈现?

标签 javascript css phantomjs webfonts

最近我正在用 phantom js 做一些实验来截取 html 代码的屏幕截图,但是我在使用 materialize icons 字体时遇到了一个奇怪的错误。

我做了一个这样的演示html

<!DOCTYPE html>
<html lang='en'>
  <head>
    <title>Demo</title>
    <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet'>
    <link href='https://fonts.googleapis.com/icon?family=Material+Icons' rel='stylesheet'> 
    <style>
         html {
            font-family: 'Roboto', sans-serif;
         }
    </style>
  </head>
  <body>
      Hello this is using roboto
      <i class='material-icons'>favorite_border</i>
  </body>
</html>

Roboto 运行良好,但 Material 图标不起作用。下图是我得到的结果: enter image description here

这应该是我得到的:

enter image description here

我认为这是因为 Material 图标使用

-webkit-font-feature-settings: 'liga'

而且 phantomjs 不支持它,我说的对吗?。很棒的字体效果很好。 有什么线索吗?

我在 ubuntu server 16.04 lts 上运行它,phantom js 是 2.1.1 感谢您的帮助

最佳答案

看起来这已在最新的 phantomjs beta 2.5 版本中修复,请参阅 https://github.com/ariya/phantomjs/issues/14885 .

另一种解决方案是自行托管 Web 前端。如果您从自己的服务器提供字体,phantomjs 可以毫无问题地呈现它。

关于javascript - 为什么 Material Icons 不在 phantom js 中呈现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43192704/

相关文章:

node.js - Nightmare 不会连续运行两次 - NodeJS

javascript - 无法将 phantom.exit() 放入 page.evaluate() 中的 phantomjs

javascript - 如何在 Loopback JS 中轻松复制模型和相关模型

jquery - 如何调整 jquery mobile 中列表项两侧的间距

javascript - phantom - 无法将循环与 page.evaluate 一起使用

php - 使用 javascript 更改背景颜色

javascript - 将唯一 ID 传递给 Javascript 以进行水平滚动

javascript - 问题设置回调结果等于对象属性(node-tesseract)

javascript - 监听表单提交

javascript - 何时(以及为什么)在 JavaScript 控制台中未定义 {}?