@font-face问题,Firefox添加了填充,Chrome没有

发布于 2024-09-12 12:28:03 字数 216 浏览 6 评论 0原文

当通过 @font-face 使用自定义字体时,它确实会像我认为在 Chrome 中那样呈现。但在 Firefox 中,字体中添加了额外的填充(顶部和底部)。

这是我概述问题的示例页面

我能做些什么吗?

When using a custom font via @font-face, it does render just as I think it should in Chrome. In Firefox, though, additional padding (top and bottom) is added to the font.

Here is my example page that outlines the problem.

Is there anything I can do about it?

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

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

发布评论

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

评论(2

︶ ̄淡然 2024-09-19 12:28:03

仅供参考,这种情况也发生在 Linux 上的 Firefox 中(而不是 Chromium 中)。我尝试在 FontForge 中加载您的字体,并立即收到警告:

字体中的以下表格已被 FontForge 忽略
忽略“LTSH”线性阈值表
忽略“VDMX”垂直设备指标表
忽略“hdmx”水平设备指标表

我认为问题在于 VDMX(垂直设备指标) 表存在缺陷:

为了避免网格拟合
整个字体以确定正确的
高度,VDMX表已
已定义。

这看起来与 Firefox 中发生的情况一模一样:某个地方的最小和最大高度计算不正确。当您选择文本时,这一点也很明显:选择框延伸到该行的最顶部和底部;如果 h1 元素确实有填充,您会看到该行的顶部和底部与选择框之间存在间隙。

此外,验证显示几乎每个字形都是“极值处缺失点”:

PostScript 和 TrueType 都会
喜欢你有最高点
和路径的最小值(极值)。

快速搜索显示:

我遇到的唯一的其他问题是
相当令人讨厌的情况称为“失踪”
指向极值”。使用字体,
需要有一个点(或节点,如
它们在 Inkscape 中被称为)
最左、最右、顶部和底部
一个字形。通常他们在那里
无论如何,只是因为你的方式
字形已构建,但对角线
圆头经常会引起问题
[来源,包括图片(向下滚动)]

FYI, this also happens in Firefox on Linux (and not in Chromium). I tried to load your font in FontForge and immediately got a warning:

The following table(s) in the font have been ignored by FontForge
Ignoring 'LTSH' linear threshold table
Ignoring 'VDMX' vertical device metrics table
Ignoring 'hdmx' horizontal device metrics table

I think the problem is that the VDMX (Vertical Device Metrics) table is defect:

In order to avoid grid fitting the
entire font to determine the correct
height, the VDMX table has been
defined.

This looks exactly like what happens in Firefox: somewhere the minimum and maximum height is incorrectly calculated. This is also clear when you select the text: the selection box extends to the utmost top and bottom of the line; if the h1 element really had padding, you would see a gap between the top and bottom of the line and the selection box.

Also, validation revealed that almost every glyph is “missing points at extrema”:

Both PostScript and TrueType would
like you to have points at the maxima
and minima (the extrema) of a path.

A quick search showed:

The only other problem I had was a
rather nasty condition called "Missing
Points at Extrema". With a font,
there needs to be a point (or node, as
they are called in Inkscape) at the
extreme left, right, top and bottom of
a glyph. Normally they are there
anyway simply because of the way your
glyph is built, but diagonal lines
with rounded ends often cause problems
[source, including picture (scroll down)]

罪歌 2024-09-19 12:28:03

只需添加:

line-height:1;

到你的 CSS 规则中

Just Add:

line-height:1;

to your CSS rules

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