Skip to content

captions.js


Variable: preloadGoogleFont()

const preloadGoogleFont: (fontFamily, options) => Promise<void> = loadGoogleFont2

Defined in: fonts/googleFonts.helpers.ts:259

Bullet-proof browser preload for Google Fonts:

  1. Fetches Google CSS
  2. Parses every returned

Parameters

fontFamily

string

options

LoadGoogleFontOptions = {}

Returns

Promise<void>

Font-face

  1. Loads each selected .woff2 via FontFace.load()
  2. Registers in document.fonts

If the exact requested weights are not available for the family (Google Fonts CSS2 API responds with 400 in that case, e.g. "PT Sans" + 900 or "Pacifico" + 500), falls back to loading 400/700 so the family is still registered and the canvas can resolve the closest available weight.