字体替代品

发布于 2024-12-22 13:47:59 字数 492 浏览 3 评论 0原文

我的客户(痴迷于像素完美)不喜欢浏览器渲染字体的方式。

目前我正在使用 font-squirrel 将 OTF 字体转换为 webfonts。

问题是,我没有看到任何替代方案。我可以创建一个包含所有这些文本的 PNG 文件,但这听起来不像是浏览器用户友好的解决方案。

我必须处理的设计的典型示例是:

饥饿游戏屏幕抓取

您的方法是什么?

我假设“不喜欢浏览器渲染@font-face的方式”你指的是发生的眨眼。如果没有,您应该详细说明。

difference

顶部一个是网络字体,底部一个是 PSD 的屏幕截图。两者都使用相同的字体系列,相同的间距。客户希望它看起来更像底部的那个。

My client (who is obsessed with pixel perfection) dislikes the way browsers render font-face fonts.

At the moment I am using font-squirrel to convert OTF fonts to webfonts.

The problem is, I don't see any alternatives. I could create a PNG file holding all these texts, but that doesn't sound like a browser-user-friendly solution.

The typical example of a design I have to work on is:

hunger games screen grab

What would be your approach?

I'm assuming that by "dislikes the way browsers render @font-face" your'e referring to the blink which happens. If not, you should elaborate.

difference

The top one is web-font and the bottom one is screengrab from PSD. Both using same font family, same spacing. The client wants to look it more like the bottom one.

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

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

发布评论

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

评论(4

2024-12-29 13:47:59

我假设“不喜欢浏览器渲染@font-face的方式”你指的是发生的眨眼。如果没有,你应该详细说明。

目前只有 3 个选项可以消除闪烁。前两个是显而易见的解决方案 - 使用图像或使用网络安全字体。显然,这些都违背了目的。

第三个选项是在 CSS 中嵌入字体的 Base64 代码。这会增加 CSS 文件的大小 (kb),但会完全消除经常发生的闪烁,因为字体是随 CSS 一起加载的,因此加载辅助文件时不会出现闪烁。

包含 bas64 字体的用法如下所示:

 @font-face {
 font-family: "FontName";
 src: url("data:font/opentype;base64,[   the base64 code here   ]");
 }

有一些在线 bas64 转换器,您可以将 .otf 文件提供给它们,它们会输出 Base64 代码。 这是一个这样的转换器。

I'm assuming that by "dislikes the way browsers render @font-face" your'e referring to the blink which happens. If not, you should elaborate.

Currently there's only 3 options to remove that blink. The first two are obvious solutions - use images, or use web safe fonts. These, obviously, defeat the purpose.

The third option is to embed base64 code for the fonts in your CSS. This increases the size (kb) of your CSS files, but it will completely eliminate the blink which tends to occur because the font is loaded with the CSS so there's no blink when a secondary file is loaded.

usage for including bas64 fonts looks like this:

 @font-face {
 font-family: "FontName";
 src: url("data:font/opentype;base64,[   the base64 code here   ]");
 }

There are a few online bas64 converters that you can feed a .otf file to and they'll spit out the base64 code. Here's one such converter.

新人笑 2024-12-29 13:47:59

我使用的一种方法是创建背景图像来表示所有显示文本,然后使用 CSS 来“隐藏”实际文本,并仅显示图像。为了可访问性,不应使用 display:none 或 display:hidden 隐藏文本。相反,使用较大的负文本缩进将文本移出显示左侧,或将其放入显示区域之外某处的嵌套、绝对定位元素中。

我通常对可点击元素中未包含的所有文本使用负缩进,并对可点击元素中包含的任何内容使用嵌套的绝对定位元素技术(因此活动元素轮廓不会像在某些浏览器)。

An approach that I have used is to create background images to represent all display-text, and then use CSS to "hide" the actual text, and show only the image. For the sake of accessibility, the text should not be hidden using display:none or display:hidden though. Instead, use a large negative text indent to move the text off the left side of the display, or put it in a nested, absolutely-positioned element somewhere outside of the display area.

I usually use the negative indentation for all text not contained in a clickable element, and the nested, absolutely positioned element technique for anything that is contained in a clickable element (so the active element outline does not expand off the left side as can happen in some browsers).

梦里泪两行 2024-12-29 13:47:59

另一种常见且流行的处理方法是自动字体替换(使用 JavaScript)。该解决方案对屏幕阅读器的用户很友好,因为 HTML 包含纯文本,并且替换是在浏览器中使用 JavaScript 完成的。

这种技术的一个例子是 sIFR,它是开源的并使用 Flash 作为替代品。

Another common and popular way of handling this is automatic font replacement (using JavaScript). This solution is friendly to users of screen readers, because the HTML contains plain text and the replacement is done using JavaScript, in the browser.

An example of this is technique is sIFR, which is open source and uses Flash as the replacement.

神经大条 2024-12-29 13:47:59

看起来好像已经加粗了。尝试将 font-weight 设置为正常。

It looks like it has been bolded. Try setting font-weight to normal.

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