Constructor
new FontFaceObserver(family, descriptors)
Parameters:
Name | Type | Description |
---|---|---|
family |
string | font-family name (required) |
descriptors |
Descriptors | an object describing the variation (optional). The object can contain `weight`, `style`, and `stretch` properties. If a property is not present it will default to `normal`. |
Members
DEFAULT_TIMEOUT :number
Type:
- number
HAS_SAFARI_10_BUG :null|boolean
Type:
- null | boolean
HAS_WEBKIT_FALLBACK_BUG :null|boolean
Type:
- null | boolean
SUPPORTS_NATIVE_FONT_LOADING :null|boolean
Type:
- null | boolean
SUPPORTS_STRETCH :null|boolean
Type:
- null | boolean
Methods
(static) getNavigatorVendor() → {string}
Returns:
- Type
- string
(static) getUserAgent() → {string}
Returns:
- Type
- string
(static) hasSafari10Bug() → {boolean}
Returns true if the browser has the Safari 10 bugs. The native font load
API in Safari 10 has two bugs that cause the document.fonts.load and
FontFace.prototype.load methods to return promises that don't reliably get
settled.
The bugs are described in more detail here:
- https://bugs.webkit.org/show_bug.cgi?id=165037
- https://bugs.webkit.org/show_bug.cgi?id=164902
If the browser is made by Apple, and has native font loading support, it is
potentially affected. But the API was fixed around AppleWebKit version 603,
so any newer versions that that does not contain the bug.
Returns:
- Type
- boolean
(static) hasWebKitFallbackBug() → {boolean}
Returns true if this browser is WebKit and it has the fallback bug which is
present in WebKit 536.11 and earlier.
Returns:
- Type
- boolean
(static) supportsNativeFontLoading() → {boolean}
Returns true if the browser supports the native font loading API.
Returns:
- Type
- boolean
(static) supportStretch() → {boolean}
Returns true if the browser supports font-style in the font short-hand
syntax.
Returns:
- Type
- boolean
load(textopt, timeoutopt) → {Promise.<FontFaceObserver>}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
text |
string |
<optional> |
Optional test string to use for detecting if a font is available. |
timeout |
number |
<optional> |
Optional timeout for giving up on font load detection and rejecting the promise (defaults to 3 seconds). |
Returns:
- Type
- Promise.<FontFaceObserver>