* Sets font faces that haven't been loaded by the time this was called to * `font-display: swap` in supported browsers. * See https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display * for details on behavior. * Swap effectively leads to immediate display of the fallback font wit
(win)
| 110 | * @param {!Window} win |
| 111 | */ |
| 112 | function timeoutFontFaces(win) { |
| 113 | const doc = win.document; |
| 114 | // TODO(@cramforce) Switch to .values when FontFaceSet extern supports it. |
| 115 | if (!doc.fonts || !doc.fonts['values']) { |
| 116 | return; |
| 117 | } |
| 118 | const it = doc.fonts['values'](); |
| 119 | let entry; |
| 120 | while ((entry = it.next())) { |
| 121 | const fontFace = entry.value; |
| 122 | if (!fontFace) { |
| 123 | return; |
| 124 | } |
| 125 | if (fontFace.status != 'loading') { |
| 126 | continue; |
| 127 | } |
| 128 | // Not supported or non-default value. |
| 129 | // If the publisher specified a non-default, we respect that, of course. |
| 130 | if (!('display' in fontFace) || fontFace.display != 'auto') { |
| 131 | continue; |
| 132 | } |
| 133 | fontFace.display = 'swap'; |
| 134 | } |
| 135 | } |
no test coverage detected