src/font-stylesheet-timeout.js
/**
 * 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 with
 * the custom font being displayed when possible.
 * While this is not the most desirable setting, it is compatible with the
 * default (which does that but only waiting for 3 seconds).
 * Ideally websites would opt into `font-display: optional` which provides
 * nicer UX for non-icon fonts.
 * If fonts set a non default display mode, this does nothing.
 * @param {!Window} win
 */
Sets font faces that haven't been loaded by the time this was called to
`font-display: swap` in supported browsers.
Sets font faces that haven ' t been loaded by the time this was called to ` font - display : swap ` in supported browsers .
function timeoutFontFaces(win) {
  if (!isExperimentOn(win, 'font-display-swap')) {
    return;
  }
  const doc = win.document;
  if (!doc.fonts && !doc.fonts['values']) {
    return;
  }
  const it = doc.fonts['values']();
  let entry;
  while ((entry = it.next())) {
    const fontFace = entry.value;
    if (!fontFace) {
      return;
    }
    if (fontFace.status != 'loading') {
      continue;
    }
    if (!('display' in fontFace) || fontFace.display != 'auto') {
      continue;
    }
    fontFace.display = 'swap';
  }
}
function timeoutFontFaces ( win ) { if ( ! isExperimentOn ( win , 'font-display-swap' ) ) { return ; } const doc = win . document ; if ( ! doc . fonts && ! doc . fonts [ 'values' ] ) { return ; } const it = doc . fonts [ 'values' ] ( ) ; let entry ; while ( ( entry = it . next ( ) ) ) { const fontFace = entry . value ; if ( ! fontFace ) { return ; } if ( fontFace . status != 'loading' ) { continue ; } if ( ! ( 'display' in fontFace ) || fontFace . display != 'auto' ) { continue ; } fontFace . display = 'swap' ; } }
Sets font faces that haven't been loaded by the time this was called to
 `font-display: swap` in supported browsers.
Sets font faces that haven ' t been loaded by the time this was called to ` font - display : swap ` in supported browsers .
// TODO(@cramforce) Switch to .values when FontFaceSet extern supports it. // Not supported or non-default value. // If the publisher specified a non-default, we respect that, of course.