谷歌浏览器字体渲染

3

我的问题是在Google Chrome Canary基础字体渲染方面遇到了一些问题。我通过Typekit将Proxima Nova字体嵌入到我正在开发的网站中。目前,该字体仅本地托管,因此我将尽力通过截图和代码示例显示问题。

长话短说,在Google Chrome Canary(当前版本为40.0.2202.3)中,每当我使用任何Web字体时,我的字体都会渲染得过于粗重。简而言之,在页面加载不到一秒钟的时间内,字体以正确的厚度呈现,然后它会在浏览器加载后的一秒钟内变得更胖。我已经尝试禁用所有插件,但问题仍然存在。当我在页面上禁用CSS时,它会与其他浏览器一致地呈现(正如人们所期望的那样)。字体在Chrome 38和39中以及所有其他主要浏览器中正确呈现。我在Windows和Mac OS上进行了测试,结果相同。我创建了一个CodePen来演示这一点,其中包含网站上已经放置的确切HTML和CSS:http://codepen.io/idealbrandon/pen/EGlDa

HTML:

<div class="wrapper">
  <aside class="masthead">
    <h1 class="h2">Advancing Drainage through J-DRain, Grid-Guard and TurfCore.</h1>
    <p class="h3">Sed consequat pretium dictum. Viva mus blandit, turpis sed es ultrices sollicitudin, risus seme finibus ipsum, in faucibus diam dolor vel felis.</p>
  </aside>
  <main>
    This is the main section
  </main>
</div>

SASS/SCSS

// Standard Measurements
$max-width:             102.4rem;
$base-font:             1.4rem;
$baseline:              $base-font*1.5;

// Media Queries
$small-up:               "only screen and (min-width: 320px)";
$small-up2:              "only screen and (min-width: 450px)";
$medium-up:              "only screen and (min-width: 600px)";
$large-up:               "only screen and (min-width: 1050px)";

// Font Declerations
$font-body:             'proxima-nova', sans-serif;
$font-icon:             'jdr';

// Color
$black:                 #000000;
$white:                 #FFFFFF;
$gray:                  #323132;
$gray-light:            #939597;
$blue:                  #0970B8;
$green:                 #38B449;

html {
  font-size: 62.5%;
  box-sizing: border-box;
  height: 100%;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: inherit;
}

body {
  margin: 0;
  padding: 0;
  height: 100%;
  font: {
    family: $font-body;
    size: 1.4rem;
  }
  color: $gray;
  background-color: $white;
  line-height: $baseline;
  -moz-osx-font-smoothing: grayscale;
   -webkit-font-smoothing: antialiased;
  //text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  height: auto;
  margin-bottom: $baseline;

  &.align-left {
    float: left;
    margin: 0 $baseline $baseline 0;
  }

  &.align-right {
    float: right;
    margin: 0 0 $baseline $baseline;
  }
}

.wrapper {
  height: 100%;
}

// Mini Reset
//// Setting type to baseline grid
p,
ul,
ol,
dl {
  margin-bottom: $baseline;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: $font-body;
  line-height: normal;
  font-weight: normal;
  margin: 0;
  margin-bottom: $baseline;
}

h1,
.h1 {
  font-size: 3.2rem;
  line-height: 3.6rem;

  @media #{$medium-up} {
    font-size: 3.6rem;
    line-height: 4.0rem;
  }
}

h2,
.h2 {
  font-size: 2.6rem;
  line-height: 3.0rem;

  @media #{$medium-up} {
    font-size: 2.8rem;
    line-height: 3.2rem;
  }
}

h3,
.h3 {
  font-size: 2.0rem;
  line-height: 2.4rem;

  @media #{$medium-up} {
    font-size: 1.8rem;
    line-height: 2.2rem;
  }
}

h4,
.h4 {
  font-size: 1.8rem;
  line-height: 2.2rem;

  @media #{$medium-up} {
    font-size: 1.4rem;
    line-height: 1.8rem;
  }
}

h5,
.h5 {
  font-size: 1.6rem;
  line-height: 2.0rem;

  @media #{$medium-up} {
    font-size: 1.2rem;
    line-height: 1.6rem;
  }
}

h6,
.h6 {
  font-size: 1.4rem;
  line-height: 1.6rem;

  @media #{$medium-up} {
    font-size: 1.0rem;
    line-height: 1.4rem;
  }
}

p,
.p {
  font-size: 1.6rem;
  line-height: $baseline;

  @media #{$medium-up} {
    font-size: 1.4rem;
    line-height: 1.8rem;
  }
}

.masthead {
  width: $baseline*20; // 420px
  background-color: $gray;
  height: 100%;
  color: $white;
  float: left;
  padding: $baseline*3 $baseline*4;
  line-height: normal;
}

main {
  background: url('build/img/city-hall.jpg') no-repeat center center fixed;
  background-size: cover;
  height: 100%;
  margin-left: $baseline*20; // This is the same distance as the width of the sidebar
}

即使通过Codepen,这个问题仍然存在。有人知道原因吗?或者我不用担心它,因为它只是一个开发版本?我的担心是,这可能会延续到以后的版本中,或者考虑到错误发生前出现了闪烁,我想知道是否有一些简单的方法来解决这个问题。
最后,这里是Canary(左侧)和Chrome Stable(右侧)并排所发生情况的截图: http://cl.ly/YFLu

尝试使用数值来定义 font-weight - DividedByZero
感谢您的建议,@RandomUser。不幸的是,这并没有解决错误。 - idealbrandon
2个回答

2
这是在简化 Mac 字体后端时引入的一个错误。该问题在 crbug.com/435822 中有提及,而问题本身已经通过 crbug.com/421412 得到解决。我不认为这个 bug 已经进入了稳定版(这一次)。
问题是“-webkit-font-smoothing:antialiased”被忽略了。对于那些不知道的人来说,这是一个 Mac 特定的属性,用于控制 CoreGraphics 应用于亚像素抗锯齿字形的伪粗体。在较大的尺寸下,这种伪粗体非常明显,因此在任何非正文文本上禁用它是可取的。更多细节可以阅读 www-style 列表上的线程“Mac 上的文本抗锯齿”,特别是 this post。那里的讨论是由于上一次这个问题破坏了并且在 Chrome 22 中进入了稳定版。
如果这种情况再次发生(仅适用于Mac的文本似乎太粗),则应打开一个Chromium bug,并提到“-webkit-font-smoothing:antialiased”似乎再次出现故障。

0

Chrome(几乎)总是在Beta版中存在字体问题。在地址栏中输入chrome://flags并启用disable directwrite,重新启动浏览器,现在应该一切正常。

顺便说一句,在我的经验中,这些字体问题总是在下一个稳定版本中得到解决,很可能FB也会看起来更加粗体。enter image description here


嗯,要么我疯了,要么Chrome已经移除了DirectWrite标志?我在标准的Chrome发布版中也没有看到它。 - idealbrandon
@idealbrandon 抱歉,我忘了提到这是一个仅适用于Windows的设置。你正在使用Windows吗?如果是的话,应该是第四个选项。 - DividedByZero
老实说,fb.com 在这两个浏览器中都能正常显示。 - idealbrandon
这是媒体查询!尝试移除它们,然后检查。 - DividedByZero
我更新了我的CodePen,但没有成功=(...我可能会等待一下,看看问题是否在以后的开发版本中得到解决。我注意到在一些网站上有这个问题,但在其他网站上没有。虽然我似乎无法找出共同点是什么。 - idealbrandon
显示剩余5条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接