PC 版 Chrome 中的 @font-face 渲染问题

发布于 2024-12-20 23:39:19 字数 1430 浏览 2 评论 0原文

我使用 font-squirrel 将字体嵌入到网站上(选择“应用提示”),但它在 PC 版 Chrome v15.0 中无法正确呈现。字体可以显示,但效果很差。我确信 font-squirrel 给了我正确的代码,所以我假设我的 CSS 中有冲突。预先感谢您的帮助。

在此处输入图像描述

网站链接

@font-face {
    font-family: 'RockwellStd-Light';
    src: url('rockwellstdlight-webfont.eot');
    src: url('rockwellstdlight-webfont.eot?#iefix') format('embedded-opentype'),
         url('rockwellstdlight-webfont.woff') format('woff'),
         url('rockwellstdlight-webfont.ttf') format('truetype'),
         url('rockwellstdlight-webfont.svg#RockwellStdLight') format('svg');
    font-weight: lighter;
    font-style: normal;

}

h1 {
    font-family:'RockwellStd-Light', Helvetica, Ariel;
    font-size:34px;
    color:#407d3b;
    font-weight:lighter;
    margin-left:20px;

}

h2 {
    font-family:'RockwellStd-Light', Helvetica, Ariel;
    font-size:32px;
    color:#ece1af;
    font-weight:lighter;
    line-height:42px;

}

h3 {
    font-family:'RockwellStd-Light', Helvetica, Ariel;
    font-size:20px;
    color:#FFF;
    font-weight:lighter;

}

p {
    font-family:'RockwellStd-Light', Helvetica, Ariel;
    font-size:14px;
    line-height:17px;
    color:#333;
    text-align:justify;

}

.criteria_table {
    font-family:'RockwellStd-Light', Helvetica, Ariel;
    font-size:14px;
    color:#FFF;

}

I used font-squirrel to embed a font onto a site (with Apply Hinting selected), and it's not rendering properly in Chrome v15.0 for PC. The font shows, but poorly. I'm sure that font-squirrel gave me the right code, so I assume there is a conflict in my CSS. Thanks in advance for your help.

enter image description here

Link to site

@font-face {
    font-family: 'RockwellStd-Light';
    src: url('rockwellstdlight-webfont.eot');
    src: url('rockwellstdlight-webfont.eot?#iefix') format('embedded-opentype'),
         url('rockwellstdlight-webfont.woff') format('woff'),
         url('rockwellstdlight-webfont.ttf') format('truetype'),
         url('rockwellstdlight-webfont.svg#RockwellStdLight') format('svg');
    font-weight: lighter;
    font-style: normal;

}

h1 {
    font-family:'RockwellStd-Light', Helvetica, Ariel;
    font-size:34px;
    color:#407d3b;
    font-weight:lighter;
    margin-left:20px;

}

h2 {
    font-family:'RockwellStd-Light', Helvetica, Ariel;
    font-size:32px;
    color:#ece1af;
    font-weight:lighter;
    line-height:42px;

}

h3 {
    font-family:'RockwellStd-Light', Helvetica, Ariel;
    font-size:20px;
    color:#FFF;
    font-weight:lighter;

}

p {
    font-family:'RockwellStd-Light', Helvetica, Ariel;
    font-size:14px;
    line-height:17px;
    color:#333;
    text-align:justify;

}

.criteria_table {
    font-family:'RockwellStd-Light', Helvetica, Ariel;
    font-size:14px;
    color:#FFF;

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

浅沫记忆 2024-12-27 23:39:19

https://stackoverflow.com/a/9041280/1112665

对于 @font-face 提供的字体,修复方法是将svg 文件位于 .eot 正下方但位于 .woff 和 .ttf 上方

从这里:

@font-face {
font-family: ‘MyWebFont’;
src: url(‘webfont.eot’); 
src: url(‘webfont.eot?#iefix’) format(‘embedded-opentype’),
     url(‘webfont.woff’) format(‘woff’),
     url(‘webfont.ttf’)  format(‘truetype’),
     url(‘webfont.svg#svgFontName’) format(‘svg’);
}

到这里:

@font-face {
font-family: ‘MyWebFont’;
src: url(‘webfont.eot’); 
src: url(‘webfont.eot?#iefix’) format(‘embedded-opentype’),
     url(‘webfont.svg#svgFontName’) format(‘svg’),
     url(‘webfont.woff’) format(‘woff’),
     url(‘webfont.ttf’)  format(‘truetype’);
}

可以在此处查看此修复的示例:

FontSpring 示例
Adtrak 示例

https://stackoverflow.com/a/9041280/1112665

For @font-face delivered fonts, the fix is to put the svg file right below .eot but above .woff and .ttf

From this:

@font-face {
font-family: ‘MyWebFont’;
src: url(‘webfont.eot’); 
src: url(‘webfont.eot?#iefix’) format(‘embedded-opentype’),
     url(‘webfont.woff’) format(‘woff’),
     url(‘webfont.ttf’)  format(‘truetype’),
     url(‘webfont.svg#svgFontName’) format(‘svg’);
}

To this:

@font-face {
font-family: ‘MyWebFont’;
src: url(‘webfont.eot’); 
src: url(‘webfont.eot?#iefix’) format(‘embedded-opentype’),
     url(‘webfont.svg#svgFontName’) format(‘svg’),
     url(‘webfont.woff’) format(‘woff’),
     url(‘webfont.ttf’)  format(‘truetype’);
}

Examples of this fix can be seen here:

FontSpring Examples
Adtrak Examples

離人涙 2024-12-27 23:39:19

您可以指定 text-shadow:

text-shadow: 0 0 1px rgba(0, 0, 0, .01);

当使用自定义字体时,使它们在 google chrome 中渲染得更好。它强制 Chrome 使用替代渲染路径。请注意,这会增加最终用户计算机上的 CPU 负载。

You can specify text-shadow:

text-shadow: 0 0 1px rgba(0, 0, 0, .01);

When using custom fonts, to make them render better in google chrome. It forces Chrome to use an alternative rendering path. Please note that this will increase CPU load on the end users machine.

忆离笙 2024-12-27 23:39:19

抱歉,大家,但这在 Chrome 16 中不再起作用。

类似的主题在这里:Windows 和 Mac 上的 @font-face 抗锯齿

我在 Google Chrome 论坛上写了相关内容,等待立即查看反应:http://www. google.com/support/forum/p/Chrome/thread?tid=43f549bc2a960a12&hl=zh-CN

I'm sorry guyes, but this doesn't work anymore in Chrome 16.

Similiar topic is here: @font-face anti-aliasing on windows and mac

And I wrote about it on Google Chrome Forum here, waiting for reactions now: http://www.google.com/support/forum/p/Chrome/thread?tid=43f549bc2a960a12&hl=en

月牙弯弯 2024-12-27 23:39:19

正如 hisnameisjimmy 已经指出的那样,解决方案是使用 SVG 字体,该字体始终使用抗锯齿进行渲染,但这也有一些缺点:

  • SVG 字体不包含任何提示信息,因此渲染的字母不像启用了字体平滑的系统上那样清晰。
  • SVG 字体的粗细和样式无法更改,因此使用 font-weight:bold;font-style:italic; 无效。

然而,至少第一个问题只有在实际禁用字体平滑功能的情况下才能通过使用 SVG 字体来解决。有一个很好的 帖子User Agent Man 介绍如何检测字体平滑,我用它创建了一个小脚本(约 600 字节),如果禁用字体平滑,它会自动更新您的字体 CSS。

您可以在 GitHub 的 GIST 上找到 我的 Font Smoothie 脚本,您所要做的就是添加在页面中的任何位置添加以下行:

<script src="fontsmoothie.min.js" type="text/javascript"></script>

但是,您还需要一个很好的 提示字体以获得漂亮的字形。幸运的是,有一种方法可以使用 ttfautohint 添加一些自动生成的提示到 ttf 字体,然后你就可以使用 Font Squirrel 生成网络字体。整个过程有点棘手,所以我写了 一篇关于如何在 Pixels|Bytes 上创建网络字体的文章,其中解释了如何向字体添加提示以及如何使用我的 Font Smoothie 脚本。希望这会有所帮助:)

PS:我知道这里不会赞赏链接到我自己的博客,但我认为我的帖子描述了该问题的一个很好的解决方案,所以我还是发布了它。如果您希望我删除该链接,请发表评论,我会这样做。

As hisnameisjimmy already pointed out, the solution is to use SVG fonts, which are always rendered with anti-aliasing, but this also has some drawbacks:

  • SVG fonts don't contain any hinting information, so the rendered letters aren't as crisp as they could be on a system that has font-smoothing enabled.
  • The weight and style of SVG fonts can't be changed, so using font-weight:bold; or font-style:italic; has no effect.

However, at least the first problem can be solved by using SVG fonts only if font-smoothing is actually disabled. There's a nice post at User Agent Man on how to detect font-smooting, which I used to create a little script (~600 bytes), which automatically updates your font-face CSS if font smoothing is disabled.

You can find my Font Smoothie script at GitHub'S GIST and all you have to do is to add the following line anywhere in your page:

<script src="fontsmoothie.min.js" type="text/javascript"></script>

However, you also need a well hinted font to get nice looking glyphs. Luckly there's a way to add some automatically generated hinting to a ttf-font using ttfautohint and you can then use Font Squirrel to generate the web-fonts. The whole process is a bit tricky so I wrote an article on how to create web-fonts on Pixels|Bytes, which explains how to add hinting to a font and how to use my Font Smoothie script. Hope this helps :)

PS: I'm aware that linking to my own blog won't be appreciated here, but I think my post describes a good solution to the problem, so I posted it anyway. Please leave a comment if you want me to remove the link and I'll do so.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文