【问题标题】:Firefox font vertical misalignment?Firefox字体垂直错位?
【发布时间】:2016-09-03 16:08:30
【问题描述】:

所以我在我的设计中使用了这种名为 Gagalin (Regular) 的网络字体,它在 Chrome 和 Edge 中运行良好。然而,当我在 FireFox 中查看它时,我得到了一个非常奇怪的垂直错位(下图)。此外,我使用的 @font-face 规则以前一直有效(也在 FireFox 中),只是不适用于这种字体,因为我使用的其他 webfont 对齐正确。关于如何解决这个问题的任何想法?我假设它与字体或?

编辑也许这不是最好的提问地方,但我真的不知道还有什么地方可以问

代码

我设置了 magin、padding 和 line-height 重置 + 我将 normalize.min.css 包含在 h1 边距中,我将其明确重置为 0 以覆盖规范化边距。标题 h1 的 line-height 也再次设置为 1。

Dropbox link to the font files

@font-face {
    font-family:'Gagalin';
    src:url(../fonts/gagalin/Gagalin-Regular.eot);
    src:url(../fonts/gagalin/Gagalin-Regular.eot?#iefix) format('embedded-opentype'),
        url(../fonts/gagalin/Gagalin-Regular.svg#Gagalin-Regular) format('svg'),
        url(../fonts/gagalin/Gagalin-Regular.woff2) format('woff2'),
        url(../fonts/gagalin/Gagalin-Regular.woff) format('woff'),
        url(../fonts/gagalin/Gagalin-Regular.otf) format('opentype');
    font-weight:400;
    font-style:normal
}

* {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;

    font-weight: normal;
    font-size: 3vm;
    font-size: 3vmin;
    line-height: 1.5;
}

h1 {
    font-family: 'Gagalin';
    margin: 0;
}

header h1 {
    line-height: 1;
}

更新 尝试删除所有字体,但 woff 字体和问题仍然相同

@font-face {
    font-family:'Gagalin';
    src:url(../fonts/gagalin/Gagalin-Regular.woff2) format('woff2'),
        url(../fonts/gagalin/Gagalin-Regular.woff) format('woff');
    font-weight:400;
    font-style:normal
}

图片

【问题讨论】:

    标签: css google-chrome firefox font-face


    【解决方案1】:

    看起来像一个不同的默认行高。明确设置行高可以解决这个问题。我们有没有机会看到您的代码来验证这一点?

    边距和内边距也是如此。我看到显式边距为零,但没有显式填充零。

    请注意,Stack Overflow 的规则要求您发送一些代码,以便我们测试/重现问题。

    【讨论】:

    • line-height 已经明确设置为 1。我添加了一个屏幕截图来验证这一点。
    【解决方案2】:

    尝试删除所有字体,或除 woff 或 woff2 之外的所有字体,看看是否是字体不一致/基线问题。

    【讨论】:

    • 试过并更新了帖子。问题在 FireFox 中仍然存在
    • 我知道这不是填充问题。否则它也会显示在检查器中,但元素的高度是正确的,并且与 chrome 和 edge 匹配,尽管字体仍然未对齐
    【解决方案3】:

    对于那些想知道的人来说,我可以通过在 Birdfont 中打开字体、导出并重新转换来解决这个问题。我真的不知道为什么 Firefox 把它搞砸了,而其他浏览器对此没有怨恨,但它现在可以工作了。

    感谢您的时间和回答

    【讨论】:

    • 不客气。所以我猜它原来是一个字体(基线定义)问题。重新转换可能会解决此问题。
    • 你应该把这个标记为答案——我想这在 Stackoverflows 标准中很酷
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-01
    • 2013-01-15
    • 1970-01-01
    • 2016-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多