如何使用 FontFace API 加载后备字体格式

How to load fallback font formats with FontFace API

当使用 FontFace API(不是@fontface)时,有没有一种方便的方法来传递多种不同的字体格式,比如在@fontface 中提供多种来源?

或者,是否有一种方便的方法来检查使用 FontFace API 的浏览器将接受哪些格式,以便我提供几种最理想的格式?

CSS Font Loading spec says, the FontFace API takes the same values as the corresponding @font-face descriptors. It means you can simply pass as the font data source whatever fallback string you’d use in your @font-face definition. It’s how WebKit handles it的当前草稿来看,反正:

let fontFace = new FontFace("MyWebFont", "url('MyWebFont.woff2') format('woff2'), url('MyWebFont.woff') format('woff')");