Class FontManager

Loads FVTT core fonts supporting FontConfig on Foundry v10+.

Note: This class contains code modified from Foundry VTT core client code. There are only so many ways to process core Foundry data structures correctly.

Constructors

Methods

  • Ensure that fonts have loaded and are ready for use. Enforce a maximum timeout in milliseconds. Proceed after that point even if fonts are not yet available.

    Parameters

    • Optionalopts: {
          document?: Document;
          editor?: boolean;
          fonts?: {
              [key: string]: globalThis.FontFamilyDefinition;
          } | {
              [key: string]: globalThis.FontFamilyDefinition;
          }[];
          ms?: number;
      }

      Optional parameters.

      • Optionaldocument?: Document

        The target document to load the fonts into.

      • Optionaleditor?: boolean

        When true verifies the editor field of FontFamilyDefinition.

      • Optionalfonts?: {
            [key: string]: globalThis.FontFamilyDefinition;
        } | {
            [key: string]: globalThis.FontFamilyDefinition;
        }[]

        A custom set of font family definitions to load. If not defined the core font family definitions are loaded.

      • Optionalms?: number

        The maximum time to spend loading fonts before proceeding.

    Returns Promise<void>