我想在我的网页中使用字体,但是在加载页面时,我会在firefox中获得以下错误消息:
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文件:
@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 (在这里我使用字体):
body
{
font-family: "Yekan";
}
发布于 2019-09-07 18:31:17
我发现了问题,我使用Filezilla上传字体到服务器,它是设置在ASCII传输模式,切换到二进制和重新上传字体问题解决。
发布于 2021-09-22 12:54:30
最近,我在服务器上的npm包bootstrap-icons
版本1.5.0的图标字体上出现了这个问题。我使用图标类,并在SCSS中用自己的类名包装它们。
我的解决方案是重新定义引导字体系列,并将字体文件复制并重命名到项目中。所以在styles.scss
中是这样的:
@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
,以确保我的重新定义仍然与上面的文件同步。
https://stackoverflow.com/questions/57835543
复制相似问题