首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何修复“可下载字体:被消毒剂拒绝”

如何修复“可下载字体:被消毒剂拒绝”
EN

Stack Overflow用户
提问于 2019-09-07 16:29:03
回答 2查看 15.2K关注 0票数 8

我想在我的网页中使用字体,但是在加载页面时,我会在firefox中获得以下错误消息:

代码语言:javascript
运行
复制
downloadable font: rejected by sanitizer (font-family: "Yekan" style:normal weight:normal stretch:normal src index:1) source: .../css/Yekan.woff2  custom.css:1:12
downloadable font: incorrect file size in WOFF header (font-family: "Yekan" style:normal weight:normal stretch:normal src index:2) source: .../css/Yekan.woff  custom.css:1:12
downloadable font: rejected by sanitizer (font-family: "Yekan" style:normal weight:normal stretch:normal src index:2) source: .../css/Yekan.woff  custom.css:1:12
downloadable font: FFTM: invalid table offset (font-family: "Yekan" style:normal weight:normal stretch:normal src index:3) source: .../css/Yekan.ttf  custom.css:1:12
downloadable font: rejected by sanitizer (font-family: "Yekan" style:normal weight:normal stretch:normal src index:3) source: .../css/Yekan.ttf  custom.css:1:12
downloadable font: CFF : table overruns end of file (font-family: "Yekan" style:normal weight:normal stretch:normal src index:4) source: .../css/Yekan.otf  custom.css:1:12
downloadable font: rejected by sanitizer (font-family: "Yekan" style:normal weight:normal stretch:normal src index:4) source: .../css/Yekan.otf

我的custom.css文件:

代码语言:javascript
运行
复制
@font-face {
    font-family: 'Yekan';
    src: url('./Yekan.eot');
    src: url('./Yekan.eot?#iefix') format("embedded-opentype"),
    url('./Yekan.woff2') format('woff2'),
    url('./Yekan.woff') format('woff'),
    url('./Yekan.ttf') format('truetype'),
    url('./Yekan.otf') format('opentype'),
    url('.//Yekan.svg#Yekan') format('svg');
    font-weight: normal;
    font-style: normal;
}

我的style.css (在这里我使用字体):

代码语言:javascript
运行
复制
body
{
   font-family: "Yekan";
}
  • 我找了很多东西,却找不到解决这个问题的办法。
  • 我以前用过这种字体,我没有问题。
  • 我检查了模因类型,它是正确的(例如,Yekan.ttf的模因类型是application/x字体-ttf)。
EN

回答 2

Stack Overflow用户

发布于 2019-09-07 18:31:17

我发现了问题,我使用Filezilla上传字体到服务器,它是设置在ASCII传输模式,切换到二进制和重新上传字体问题解决。

票数 7
EN

Stack Overflow用户

发布于 2021-09-22 12:54:30

最近,我在服务器上的npm包bootstrap-icons版本1.5.0的图标字体上出现了这个问题。我使用图标类,并在SCSS中用自己的类名包装它们。

我的解决方案是重新定义引导字体系列,并将字体文件复制并重命名到项目中。所以在styles.scss中是这样的:

代码语言:javascript
运行
复制
@font-face {
  font-family: "bootstrap-icons-redef";
  src: url("../assets/fonts/bootstrap-icons-redef.woff2") format("woff2"),
  url("../assets/fonts/bootstrap-icons-redef.woff") format("woff");
}

这个解决方案的一个小缺点是,我必须在每次更新时检查node_modules/bootstrap-icons/font/bootstrap-icons.css,以确保我的重新定义仍然与上面的文件同步。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57835543

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档