CSS -webkit-font-smoothing 属性在 Chrome 中无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18786829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
-webkit-font-smoothing property has no effect in Chrome
提问by Gavin
I'm trying to control Google Chrome's (horrible) font anti-aliasing using the -webkit-font-smoothing
CSS property, but it's having absolutely no effect on the text.
我正在尝试使用-webkit-font-smoothing
CSS 属性控制 Google Chrome 的(可怕的)字体抗锯齿功能,但它对文本完全没有影响。
<div style="font-size: 42px">
<p style="-webkit-font-smoothing: subpixel-antialiased">This is a font test.</p>
<p style="-webkit-font-smoothing: antialiased">This is a font test.</p>
<p style="-webkit-font-smoothing: none">This is a font test.</p>
</div>
I've compared the pixels in Photoshop and all three are exactly the same. Is Chrome not supporting this property anymore?
我比较了 Photoshop 中的像素,这三个像素完全相同。Chrome 不再支持此属性了吗?
回答by BenM
https://productforums.google.com/forum/?fromgroups=#!topic/chrome/0vqp1bnkaoE
https://productforums.google.com/forum/?fromgroups=#!topic/chrome/0vqp1bnkaoE
-webkit-font-smoothing no longer works. Google Chrome team intentionally changed this behavior. Seems font-smoothing wasn't applied "properly" on OSX in previous versions.
-webkit-font-smoothing 不再有效。Google Chrome 团队有意改变了这种行为。在以前的版本中,似乎没有在 OSX 上“正确”应用字体平滑。
回答by Jayesh Amin
Well you are right. Font-smoothing is not supported now. It is not in new css standards. So, No more font-smoothing.! YOu may wanna see w3c standards here. http://www.w3.org/TR/WD-font/#font-smooth
好吧,你是对的。现在不支持字体平滑。它不在新的 css 标准中。所以,没有更多的字体平滑。!你可能想在这里看到 w3c 标准。 http://www.w3.org/TR/WD-font/#font-smooth
回答by internetgho5t
If you are using a browser or OS that does not have font rendering than this will not work, have you tried -moz-
-o-
, Chrome works on -webkit-
it has to be your browser.
如果您使用的浏览器或操作系统没有字体渲染,那么这将不起作用,您是否尝试过-moz-
-o-
,Chrome-webkit-
必须是您的浏览器。
回答by tinynow
It seems that for some (system?) fonts, there is a difference between your test cases:
似乎对于某些(系统?)字体,您的测试用例之间存在差异:
body {
font-family: "HelveticaNeue-Light";
font-weight: 300;
}
回答by Gener Cruz
Try this CSS:
试试这个 CSS:
div {
-webkit-text-stroke: 0.6px;
}
<div style="font-size: 42px">
<p style="-webkit-font-smoothing: subpixel-antialiased">This is a font test.</p>
<p style="-webkit-font-smoothing: antialiased">This is a font test.</p>
<p style="-webkit-font-smoothing: none">This is a font test.</p>
</div>
回答by Rizo
You can try syntax:
您可以尝试语法:
/* Keyword values */
font-smooth: auto;
font-smooth: never;
font-smooth: always;
/* <length> value */
font-smooth: 2em;
Though present in early (2002) drafts of CSS3 Fonts, font-smooth was removed and this specification is not on the standards track. https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth
尽管出现在 CSS3 字体的早期(2002 年)草案中,但 font-smooth 已被删除,并且该规范不在标准轨道上。 https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth