最近我正在用 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 图标不起作用。下图是我得到的结果:
这应该是我得到的:
我认为这是因为 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/