captions.js
API ReferenceVariables

preloadGoogleFont

Bullet-proof browser preload for Google Fonts: 1) Fetches Google CSS 2) Parses every returned

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

Bullet-proof browser preload for Google Fonts:

  1. Fetches Google CSS
  2. Parses every returned

Parameters

ParameterType
fontFamilystring
optionsLoadGoogleFontOptions

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.

For AI agents and LLMs: this page as Markdown · llms.txt · all docs in one file