FontFace

这是 实验性技术
检查 浏览器兼容性表格 在生产中使用这之前。

FontFace interface represents a single usable font face. It allows control of the source of the font face, being a URL to an external resource, or a buffer; it also allows control of when the font face is loaded and its current status.

构造函数

FontFace()
Constructs and returns a new FontFace object, built from an external resource described by an URL or from an ArrayBuffer .

特性

This interface doesn't inherit any property.

FontFace.display
A CSSOMString that determines how a font face is displayed based on whether and when it is downloaded and ready to use.
FontFace.family
A CSSOMString that retrieves or sets the family of the font. It is equivalent to the font-family descriptor.
FontFace.featureSettings
A CSSOMString that retrieves or sets infrequently used font features that are not available from a font's variant properties. It is equivalent to the font-feature-settings descriptor.
FontFace.loaded 只读
返回 Promise that resolves with the current FontFace object when the font specified in the object's constructor is done loading or rejects with a SyntaxError .
FontFace.status 只读
Returns an enumerated value indicating the status of the font, one of "unloaded" , "loading" , "loaded" ,或 "error" .
FontFace.stretch
A CSSOMString that retrieves or sets how the font stretches . It is equivalent to the font-stretch descriptor.
FontFace.style
A CSSOMString that retrieves or sets the style of the font. It is equivalent to the font-style descriptor.
FontFace.unicodeRange
A CSSOMString that retrieves or sets the range of unicode codepoints encompassing the font. It is equivalent to the unicode-range descriptor.
FontFace.variant
A CSSOMString that retrieves or sets the variant of the font. It is equivalent to the font-variant descriptor.
FontFace.weight
A CSSOMString that contains the weight of the font. It is equivalent to the font-weight descriptor.

方法

This interface doesn't inherit any method.

FontFace.load()
Loads a font based on current object's constructor-passed requirements, including a location or source buffer, and returns a Promise that resolves with the current FontFace object.

规范

规范 状态 Comment
CSS Font Loading Module Level 3
The definition of 'FontFace' in that specification.
工作草案 初始定义

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
FontFace Chrome 35 Edge 79 Firefox 41 IE ? Opera 22 Safari 10 WebView Android 37 Chrome Android 35 Firefox Android 41 Opera Android 22 Safari iOS 10 Samsung Internet Android 4.0
FontFace() 构造函数 Chrome 35 Edge 79 Firefox 41 IE ? Opera 22 Safari 10 WebView Android 37 Chrome Android 35 Firefox Android 41 Opera Android 22 Safari iOS 10 Samsung Internet Android 4.0
display
Chrome 60 Edge 79 Firefox 58 IE ? Opera 47 Safari 11 WebView Android 60 Chrome Android 60 Firefox Android No Opera Android 44 Safari iOS No Samsung Internet Android 8.0
family
Chrome 35 Edge 79 Firefox Yes IE ? Opera Yes Safari 10 WebView Android 37 Chrome Android 35 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
featureSettings
Chrome 35 Edge 79 Firefox Yes IE ? Opera Yes Safari 10 WebView Android 37 Chrome Android 35 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
load
Chrome 45
45
不支持 35 — 45
Before Chrome 45, the returned promise resolved with void instead of a FontFace object as required by the specification.
Edge 79 Firefox Yes IE ? Opera Yes Safari 10 WebView Android 45
45
不支持 37 — 45
Before WebView 45, the returned promise resolved with void instead of a FontFace object as required by the specification.
Chrome Android 45
45
不支持 35 — 45
Before Chrome 45, the returned promise resolved with void instead of a FontFace object as required by the specification.
Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 5.0
5.0
不支持 4.0 — 5.0
Before Samsung Internet 5.0, the returned promise resolved with void instead of a FontFace object as required by the specification.
loaded
Chrome 45
45
不支持 35 — 45
Before Chrome 45, the returned promise resolved with void instead of a FontFace object as required by the specification.
Edge 79 Firefox Yes IE ? Opera Yes Safari 10 WebView Android 45
45
不支持 37 — 45
Before WebView 45, the returned promise resolved with void instead of a FontFace object as required by the specification.
Chrome Android 45
45
不支持 35 — 45
Before Chrome 45, the returned promise resolved with void instead of a FontFace object as required by the specification.
Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 5.0
5.0
不支持 4.0 — 5.0
Before Samsung Internet 5.0, the returned promise resolved with void instead of a FontFace object as required by the specification.
status
Chrome 35 Edge 79 Firefox Yes IE ? Opera Yes Safari 10 WebView Android 37 Chrome Android 35 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
stretch
Chrome 35 Edge 79 Firefox Yes IE ? Opera Yes Safari 10 WebView Android 37 Chrome Android 35 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
style
Chrome 35 Edge 79 Firefox Yes IE ? Opera Yes Safari 10 WebView Android 37 Chrome Android 35 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
unicodeRange
Chrome 35 Edge 79 Firefox Yes IE ? Opera Yes Safari 10 WebView Android 37 Chrome Android 35 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
variant
Chrome 35 Edge 79 Firefox Yes IE ? Opera Yes Safari 10 WebView Android 37 Chrome Android 35 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
weight
Chrome 35 Edge 79 Firefox Yes IE ? Opera Yes Safari 10 WebView Android 37 Chrome Android 35 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
Available in workers Chrome 69 Edge 79 Firefox ? IE ? Opera ? Safari ? WebView Android 69 Chrome Android 69 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 10.0

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
见实现注意事项。

另请参阅