【问题标题】:CSS Font family not working in FirefoxCSS字体系列在Firefox中不起作用
【发布时间】:2015-10-21 18:55:58
【问题描述】:

嘿,我在 scss 文件中有以下代码:

@font-face {
    font-family: 'tr-icon';
    src:url('../fonts/tr-icon.eot?88d087');
    src:url('../fonts/tr-icon.eot?#iefix88d087') format('embedded-opentype') ,
        url('../fonts/tr-icon.ttf?88d087') format('truetype') ,
        url('../fonts/tr-icon.woff?88d087') format('woff') ,
        url('../fonts/tr-icon.svg?88d087#trends') format('svg') ;
    font-weight: normal;
    font-style: normal;
}
[class^="tr-icon-"], [class*=" tr-icon-"] {
    font-family: 'tr-icon';
    speak: none;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
}

它被 Firefox 拒绝并出现以下错误:

downloadable font: rejected by sanitizer (font-family: "tr-icon" style:normal weight:normal stretch:normal src index:0)

我就是无法让它工作。我尝试了不同的解决方法,如 https://jamie.curle.io/posts/firefox-font-rejected-by-sanitzer/ 或 https://github.com/Semantic-Org/Semantic-UI/issues/2121,但似乎没有任何效果......还有其他想法吗?

【问题讨论】:

    标签: html css firefox fonts


    【解决方案1】:

    你试过了吗?

    删除了每行末尾的查询字符串?

    @font-face {
        font-family: 'tr-icon';
        src:url('../fonts/tr-icon.eot');
        src:url('../fonts/tr-icon.eot?#iefix') format('embedded-opentype') ,
            url('../fonts/tr-icon.ttf') format('truetype') ,
            url('../fonts/tr-icon.woff') format('woff') ,
            url('../fonts/tr-icon.svg#trends') format('svg') ;
        font-weight: normal;
        font-style: normal;
    }
    

    由于每个 url/路径末尾的查询字符串是您的字体被 sanitizer 拒绝的原因。

    【讨论】:

    • 是的,我得到了完全相同的错误,没有查询字符串可下载字体:被消毒剂拒绝(字体系列:“tr-icon”样式:正常重量:正常拉伸:正常 src 索引:0)来源:fonts/tr-icon.eot
    • 这意味着您的 css 预处理器仍在广告这些字符串。您是否将字体部分移出 scss 部分?
    • 哦,天哪,我确实做到了,但我进入 css 文件时,一些 scss 代码无法识别,它搞砸了一切。它现在正在工作:)
    • 太好了,从 2 天以来一直在尝试找到此解决方案.. 这解决了问题。我不明白为什么 Font Awesome 支持网站上没有这个解决方案。他们为什么要创建这个错误?
    猜你喜欢
    • 2013-02-25
    • 2015-06-21
    • 2012-06-18
    • 2017-05-08
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    • 2022-11-26
    相关资源
    最近更新 更多