CSS:@font-face 抗锯齿

发布于 2024-09-13 08:39:51 字数 591 浏览 4 评论 0 原文

我对 @font-face CSS 选项有点挣扎。经过大量阅读、尝试、重试后,我终于找到了一个网站,当您上传字体时,它可以为您提供现成的软件包。它现在正在运行,但似乎字体没有消除锯齿。虽然我在其他网站上看到这种情况发生,但我的网站没有按照我想要的方式呈现标题。

我的 CSS 代码:

@font-face {
font-family: 'YanoneKaffeesatzThin';
src: url('../fonts/yanonekaffeesatzthin-webfont.eot');
src: local('☺'), url('../fonts/yanonekaffeesatzthin-webfont.woff') format('woff'), url('../fonts/yanonekaffeesatzthin-webfont.ttf') format('truetype'), url('../fontsyanonekaffeesatzthin-webfont.svg#webfontyC5sm3N9') format('svg');
font-weight: normal;
font-style: normal;}

还需要做什么才能让这个最后但烦人的问题消失?

I'm a bit struggling with the @font-face CSS option. After a lot of reading, trying, retrying I finally came across a website that makes you a ready-to-go package when you upload your font. It's running now but it seems the font doesn't get anti-aliased. While I see this happening at other websites, mine does not render the headings the way I want.

My CSS code:

@font-face {
font-family: 'YanoneKaffeesatzThin';
src: url('../fonts/yanonekaffeesatzthin-webfont.eot');
src: local('☺'), url('../fonts/yanonekaffeesatzthin-webfont.woff') format('woff'), url('../fonts/yanonekaffeesatzthin-webfont.ttf') format('truetype'), url('../fontsyanonekaffeesatzthin-webfont.svg#webfontyC5sm3N9') format('svg');
font-weight: normal;
font-style: normal;}

What is left to do to make this last, but anoying, issue go away?

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

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

发布评论

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

评论(5

泛滥成性 2024-09-20 08:39:51

另请参阅:http://www.elfboy.com/blog/text-shadow_anti-aliasing/

要点是添加 text-shadow: 0 0 1px rgba(0,0,0,0.3); 给出抗锯齿的外观。

Also see: http://www.elfboy.com/blog/text-shadow_anti-aliasing/

The gist is that adding text-shadow: 0 0 1px rgba(0,0,0,0.3); gives the appearance of anti-aliasing.

夜吻♂芭芘 2024-09-20 08:39:51

对于 CSS3,您可以使用 font-smooth 属性,尽管抗锯齿仍然由系统默认值控制。如果您确实需要强制执行干净的抗锯齿功能,无论操作系统是什么,您都必须使用 sIFR,它会自动用 Flash 组件替换文本。

With CSS3, you can use the font-smooth property, although antialiasing will still be controlled by the system defaults. If you really need to force a clean antialiasing no matter what the OS is, you have to use sIFR which automatically replace the text with a Flash component.

海的爱人是光 2024-09-20 08:39:51

只是关于处理抗锯齿的不那么常见的 CSS 规则的简短说明。

-webkit-font-smoothing: antialiased;

webkit 浏览器的字体渲染会略有不同。一般来说,字体显得更清晰、更细。其他值:

-webkit-font-smoothing: subpixel-antialiased;
-webkit-font-smoothing: none;

演示页面: http://maxvoltar.com/sandbox/fontsmoothing/

不要忘记https://developer.mozilla.org/en-US/docs /Web/CSS/Reference/Webkit_Extensions

Just a short note about a not so common CSS rule to deal with antialias.

-webkit-font-smoothing: antialiased;

You will have a slight variation in the font rendering for webkit browsers. Generally the font appear more clear and thin. Other values:

-webkit-font-smoothing: subpixel-antialiased;
-webkit-font-smoothing: none;

A demo page: http://maxvoltar.com/sandbox/fontsmoothing/

Not to forget https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Webkit_Extensions

油焖大侠 2024-09-20 08:39:51

您需要将 OTF 转换为 WOFF:


OTF -> WOFF(有效!)

TTF -> OTF-> WOFF(有效!)

TTF -> WOFF(无法抗锯齿,这是 Google Fonts 中的常见错误)


1°) 下载 OTF 字体版本

1° 替代)如果字体是其他字体并且是 TTF,请使用 https://everythingfonts.com/ttf-to-otf

2°) 将 OTF 转换为 WOFF https://everythingfonts.com/otf-to-woff


仅使用 WOFF,而不是 EOT、SVG、WOFF2 等。

You need to convert OTF to WOFF:


OTF -> WOFF (Works!)

TTF -> OTF -> WOFF (Works!)

TTF -> WOFF (Doesn't work antialising, common mistake in Google Fonts)


1º) Download the OTF font version

1º alternative) If the font is other and is TTF, convert it to OTF with https://everythingfonts.com/ttf-to-otf

2º) Convert OTF to WOFF https://everythingfonts.com/otf-to-woff


Use only WOFF not EOT, SVG, WOFF2, etc..

∝单色的世界 2024-09-20 08:39:51

Cufon 和 Typeface.js 是两个解决方案,它们聚合并清理了本线程中讨论的大量 HTML5、CSS3 和 JS 解决方案。

每个都有一个转换器,允许将字体文件(ttf、otf、wotf)转换为脚本,以执行您想要执行的操作 - 通过网络提供任何抗锯齿字体。

两者中,我更喜欢 Cufon http://cufon.shoqolate.com/generate/

Cufon and Typeface.js are two solutions that aggregate and sanitize a lot of the HTML5, CSS3 and JS solutions discussed in this thread.

Each has a converter allowing font files (ttf, otf, wotf) to be converted to scripts that do what you're trying to do -- deliver any font over the web, antialiased.

Of the two, I prefer Cufon http://cufon.shoqolate.com/generate/

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