forked from GoogleChrome/samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
26 lines (23 loc) · 1.16 KB
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function logLoaded(fontFace) {
ChromeSamples.log(fontFace.family, 'loaded successfully.');
}
// Loading FontFaces via JavaScript is alternative to using CSS's @font-face rule.
var bitterFontFace = new FontFace('Bitter', 'url(https://fonts.gstatic.com/s/bitter/v7/HEpP8tJXlWaYHimsnXgfCOvvDin1pK8aKteLpeZ5c0A.woff2)');
document.fonts.add(bitterFontFace);
bitterFontFace.loaded.then(logLoaded);
var oxygenFontFace = new FontFace('Oxygen', 'url(https://fonts.gstatic.com/s/oxygen/v5/qBSyz106i5ud7wkBU-FrPevvDin1pK8aKteLpeZ5c0A.woff2)');
document.fonts.add(oxygenFontFace);
oxygenFontFace.loaded.then(logLoaded);
// The .ready promise resolves when all fonts that have been previously requested
// are loaded and layout operations are complete.
document.fonts.ready.then(function() {
ChromeSamples.log('There are', document.fonts.size, 'FontFaces loaded.\n');
// document.fonts has a Set-like interface. Here, we're iterating over its values.
for (var fontFace of document.fonts.values()) {
ChromeSamples.log('FontFace:');
for (var property in fontFace) {
ChromeSamples.log(' ' + property + ': ' + fontFace[property]);
}
ChromeSamples.log('\n');
}
});