css - 旧式数字 ("onum") 在 Chrome 中不起作用

标签 css google-chrome webfonts typography opentype

使用 旧式图形 OpenType 功能和 font-feature-settings: "onum" 在 Chrome 中不起作用。它适用于所有其他主要浏览器,例如适用于 Mac 和 iOS 的 Safari 以及 Firefox。

如何在 Chrome 中也能使用的网络字体中激活旧式图形


OpenType figures


这是一个例子:

@font-face {
  font-family: "Garamond Premier Pro Display";
  font-weight: 700;
  font-style: normal;
  font-feature-settings: "onum"; /* Activate oldstyle figures */
  src: url("https://use.typekit.net/af/6abdec/00000000000000003b9ade3b/27/l?primer=7cdcb44be4a7db8877ffa5c0007b8dd865b3bbc383831fe2ea177f62257a9191&fvd=n7&v=3") format("woff2")
}

html, body { height: 100% }

body {
  display: grid;
  place-items: center
}

h1 { font: 700 calc(9rem / 2)/1 "Garamond Premier Pro Display" }
<h1>1776</h1>

最佳答案

我正在为遇到此问题的任何人发布问答。经过大量的反复试验,我想出了怎么做。

要在 Chrome 中激活旧式图形,需要使用:

font-variant-numeric: oldstyle-nums

@font-face {
  font-family: "Garamond Premier Pro Display";
  font-weight: 700;
  font-style: normal;
  font-feature-settings: "onum"; /* Activate oldstyle figures */
  src: url("https://use.typekit.net/af/6abdec/00000000000000003b9ade3b/27/l?primer=7cdcb44be4a7db8877ffa5c0007b8dd865b3bbc383831fe2ea177f62257a9191&fvd=n7&v=3") format("woff2")
}

html, body { height: 100% }

body {
  display: grid;
  place-items: center
}

h1 {
  font: 700 4.5rem/1 "Garamond Premier Pro Display";
  font-variant-numeric: oldstyle-nums /* Activate oldstyle figures in Chrome */
}
<h1>1776</h1>

关于css - 旧式数字 ("onum") 在 Chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58806621/

相关文章:

css - 使用 webfonts 在输入字段中垂直定位文本

css - 如何将 Bootstrap 中的两行合并为一列

html - 如何使中心裁剪图像响应?

css - 增加浏览器缩放时 mediaelement.js 音量控制困惑

javascript - Chrome 调试协议(protocol) : Create local storage value

html - Chrome 中的表单 - 奇怪的 css 渲染

javascript - 带有文本div slider jquery的图像内容 slider

jquery ui-autocomplete 和 google chrome 自动完成

css - Google 字体未在 WordPress 网站中呈现

css - 将网络字体转换和呈现为 base64 - 保持原始外观