【问题标题】:Chrome not rendering @font-face ttf/woff smoothChrome 不渲染@font-face ttf/woff 平滑
【发布时间】:2012-05-14 18:40:12
【问题描述】:

我正在为我正在处理的项目使用 IconMoon @font-face 图标字体。

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

【问题讨论】:

    标签: css icons font-face smooth


    【解决方案1】:

    我发现这适用于该问题。我不认为字体平滑的解决方案真的有效。

    @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 将选择列表中的最后一个 (woff),无论是否工作,IE 将使用 eot,并且 Chrome 会选择第一个有效的(svg)。 Woff 在 chrome 中也可以使用,但会导致 别名字形,因此将 svg 放在 woff 之前可以解决这个问题。*

    此解决方案有效,但会在 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/

    【讨论】:

    【解决方案2】:

    将 svg 字体的 url 放在所有其他字体之前,Chrome 将加载 SVG,您将获得漂亮的渲染效果,尤其是浅色字体。

    【讨论】:

    【解决方案3】:

    试试这个字体的小旋转,希望对你有帮助。

    例子:

    p{
      transform: rotate(-0.0000000001deg);
    }
    

    【讨论】:

    • 哈哈。这有点工作。可悲的是,工作的最小度数是 0.1 度。这使页面看起来很不稳定。
    【解决方案4】:

    也许这个 css 属性可以解决你的问题:

    yourSelector {
      font-smooth: always;
      -webkit-font-smoothing: antialiased;
    }
    

    【讨论】:

    • 顺便说一句,唯一支持“eot”格式的浏览器是IE。 chrome 也支持“svg”格式,您可以在@font-face 样式规则中包含指向“svg”文件的链接,但如果还提供了“ttf”或“otf”链接,大多数浏览器会更喜欢使用它们。
    猜你喜欢
    • 2014-09-15
    • 2011-07-08
    • 1970-01-01
    • 2012-02-15
    • 2011-09-14
    • 2011-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多