css - Chrome 不渲染 @font-face ttf/woff 平滑

标签 css icons font-face smoothing

我正在为我正在进行的元素使用 IconMoon @font-face 图标字体。

仅包含 .svg 和/或 .eot 字体时,或使用其他浏览器(如 IE9)浏览时,字体呈现流畅流畅。但是当使用 Chrome 浏览网站时,包括 .ttf 和/或 .woff 格式,图标变得非常不稳定并且根本没有消除锯齿。有没有办法告诉 Chrome 加载 .eot 或 .svg 而不是 .ttf 或 .woff?

最佳答案

I found this works for that issue. I don't think the font-smooth solution actually works.

@font-face {
   font-family: 'Montserrat';
   font-style: normal;
   font-weight: 400;
   src: url('fonts/montserrat-regular-webfont.eot'); /* IE9 Compat Modes */
   src: url('fonts/montserrat-regular-webfont.eot?iefix') format('eot'), 
       url('fonts/montserrat-regular-webfont.ttf')  format('truetype'), 
       url('fonts/montserrat-regular-webfont.svg#montserratregular') format('svg'),
       url('fonts/montserrat-regular-webfont.woff') format('woff'); 
}

Firefox will pick the last one in the list (woff), working or not, IE will use eot, and Chrome will pick the first one that works (svg). Woff works too in chrome, but causes aliased glyphs, so putting svg ahead of woff solves that.*

此解决方案有效,但会在 Safari 中引起额外请求,您可以像最初那样将 svg 保留在 woff 下方并添加:

@media screen and (-webkit-min-device-pixel-ratio:0) {
  @font-face {
    font-family: 'OpenSansLightItalic';
    src: url('fonts/montserrat-regular-webfont.svg#montserratregular')  format('svg');
  }
}

在这里阅读:http://hollisterdesign.wordpress.com/2014/04/29/note-to-self-always-use-this-fix/

关于css - Chrome 不渲染 @font-face ttf/woff 平滑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10462040/

相关文章:

html - 使用字体在 HTML 中使用本地字体

html - 在 CSS3 中模拟多页文档

android - Android 中缺少启动器图标

css - 使用 CSS3 font-face 的正确方法是什么?

css - SVG 动画图标使用 css 使尺寸更大

python - Pyinstaller 创建的 PyQt 应用程序中的图标无法在其他计算机上使用

css - 使用正确的本地字体名称

html - 基于 css 的链接悬停激活/停用 div

html - 全高响应式 img

html - 强制用户代理样式表