我使用FontForge创建了一些图标,这些图标可以在除Safari之外的所有现代浏览器中使用。是什么原因导致Safari成为唯一不显示字体的浏览器?
这是正在使用的SCSS:
@font-face {
font-family: 'MyFont';
src: url('/assets/fonts/MyFont.woff2') format('woff2');
font-weight: normal;
font-style: normal;
}
.my-font-icon {
font-family: 'MyFont';
display: inline-block;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
text-rendering: auto;
line-height: 1;
-webkit-font-smoothing: antialiased;
&:before {
font-family: 'MyFont';
display: inline-block;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
text-rendering: auto;
line-height: 1;
-webkit-font-smoothing: antialiased;
}
&.my-font-questions:before {
content: "\0001";
}
&.my-font-chevron-left:before {
content: "\0002";
}
&.my-font-close:before {
content: "\0003";
}
}发布于 2020-03-09 04:25:05
Safari需要TrueType/ttf字体版本,实际上您应该包含几种不同的类型,而不仅仅是woff2,后者是最现代的类型。以下是CSS Tricks文章here中的示例列表,浏览器会找到它能识别的字体并呈现该字体:
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff2') format('woff2'), /* Super Modern Browsers */
url('webfont.woff') format('woff'), /* Pretty Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}FontForge应该为您提供这些其他字体类型,但如果它不提供,您将需要转到FontSquirrel来呈现它们(如果您有这样做的许可证和权限):
https://stackoverflow.com/questions/60591667
复制相似问题