Safari 第一次下载字体失败(无缓存),但重新加载页面后就可以了。存储的字体文件存储在服务器上。
字体规则:
@font-face {
font-family: Museo Sans Cyrl;
font-style: normal;
font-weight: 100;
font-display: swap;
src:
url("../fonts/MuseoSansCyrl/MuseoSansCyrl100.ttf") format("truetype"),
url("../fonts/MuseoSansCyrl/MuseoSansCyrl100.woff2") format("woff2"),
url("../fonts/MuseoSansCyrl/MuseoSansCyrl100.otf") format("opentype");
}
其他字体粗细也一样
如果直接点击链接,文件正在下载。
尝试使用 font-face,从不同文件甚至其他服务器下载字体
您很可能可以通过
来缓解这个问题woff2
格式。目前 safari 将加载更大的 .ttf
文件。@font-face {
font-family: Museo Sans Cyrl;
font-style: normal;
font-weight: 100;
font-display: swap;
src: url("../fonts/MuseoSansCyrl/MuseoSansCyrl100.woff2") format("woff2"),
url("../fonts/MuseoSansCyrl/MuseoSansCyrl100.ttf") format("truetype"),
url("../fonts/MuseoSansCyrl/MuseoSansCyrl100.otf") format("opentype");
}
preload属性的
<link>
标签添加到 HTML <head>
<link rel="preload" href="../fonts/MuseoSansCyrl/MuseoSansCyrl100.woff2" as="font" type="font/woff2" crossorigin>
来自 mdn 文档
这确保它们更早可用并且不太可能被阻止 页面的渲染,提高性能。尽管名字 包含术语 load,它不会加载并执行脚本,但是 只安排它以更高的优先级下载和缓存。