html - 在带有 Noscript 的 Firefox 中对 html/css 字体使用 @import(Google 字体不呈现)?

标签 html css firefox fonts

类似 https://css-tricks.com/snippets/css/using-font-face/ 的资源请注意,CSS @import 规则可用于字体,尤其是 Google 字体:

@import url(//fonts.googleapis.com/css?family=Open+Sans);

因此,我尝试编写以下最小示例(存储在本地 PC 中,例如 /tmp/ttt.htm):

<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Oxygen:400,700);
body {
  /*font: 18px/27px 'Oxygen', sans-serif;*/
  font-family: 'Oxygen', sans-serif;
  font-size: 18px;
  line-height: 27px;
}
  </style>
</head>

<body>
 Testing a font here
</body>
</html>

但是,如果我在 Firefox 42 中使用 NoScript 打开它 - 即使/当我允许 file:// 协议(protocol)时 - 我会得到这样的渲染:

ff-css-font

...也就是说,好像完全忽略了@import;如果我打开 http://fonts.googleapis.com 也会发生同样的情况在不同的选项卡中,在 NoScript 中允许它,然后我返回到本地 HTML 并在那里刷新它。但是,如果我打开一个新的 Firefox 实例,例如:

firefox -no-remote -P "some other profile" /tmp/ttt.htm

...然后字体被正确渲染。

有没有什么方法可以在 Firefox 的 NoScript 中正确呈现这个例子 - 一旦给出了 NoScript 权限?

最佳答案

NoScript 默认阻止网络字体。这包括@font-face 和@import。这是一个可配置的偏好:

NoScript menu → Options... → Embeddings tab → Forbid @font-face

这是因为庞大的 FreeType 字体库最初并非设计用于通过网络加载不受信任的内容。它在过去 5 年中存在已知漏洞, future 可能会出现漏洞。

关于html - 在带有 Noscript 的 Firefox 中对 html/css 字体使用 @import(Google 字体不呈现)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33887285/

相关文章:

html - R Markdown HTML数字数字

javascript - JQuery 在 div 中选择多个 img 之一

jquery - 如何在同一行引导模型中强制两个元素对齐

html - 如何删除 wordpress 主题中横幅和内容之间的空格?

javascript - 滚动 safari bug 上元素的增长高度

javascript - Stripe支付无法使用

javascript - 如何使 HTML 元素仅在特定屏幕尺寸下可点击

firefox - Selenium IDE : cannot run a test case or switch to the command table

javascript - Firefox 不执行动态加载的 JavaScript 文件

javascript - Firefox 在每次请求 Promise ajax 调用时弹出 "This web page is being redirected to a new location"- 有什么办法可以避免吗?