@twip/web
    Preparing search index...

    Class FontLibrary

    The fonts editors draw with. Share one per page: every editor on the page uses FontLibrary.default, and a font added there reaches every editor, including ones already open.

    Index
    • Adds font files: TTF, OTF and TTC bytes, or a URL to fetch them from.

      Parameters

      • source: string | Uint8Array<ArrayBufferLike> | URL

      Returns Promise<FaceInfo[]>

    • Sets the aliases, replacing earlier ones: { Arial: 'Arimo' }, or aliases per style or to a generic category ({ from: 'Garamond', to: { category: 'serif' } }). An alias applies only when its family isn't in the library; the document keeps naming it. Families a resolver answered, or found missing, are requested again.

      Parameters

      • aliases: Record<string, string> | Alias[]

      Returns void

    • Sets the families searched, in order, for a character a run's font lacks, before the symbol fallback.

      Parameters

      • families: string[]

      Returns void

    • Sets whether a document's font table gives a missing family its generic category. On by default; it has no effect until a generic default is set. Off, only aliases to a category and resolver answers give one.

      Parameters

      • options: { fromDocument: boolean }

      Returns void

    • Sets the general fallback: the family that draws a font nothing else resolves (after replacements, aliases, resolver answers and generic defaults). With null, or when it isn't in the library, the first face added draws.

      Parameters

      • family: string | null

      Returns void

    • Sets the draw-time replacements, replacing earlier ones: { 'Times New Roman': 'Tinos' }, or rules per style. A replacement is the first step of resolution and applies even when the replaced family is in the library.

      Parameters

      • rules: Record<string, string> | FontRule[]

      Returns void

    • Sets the resolver: the engine asks it, once per family and style, for a font a document uses that the library doesn't have. The request carries the document's description of the family and the category it gives. Resolve with the font's bytes or a URL, { family } or { category } to draw it with another family or a category's default, or null. While it runs, the family is in state.fonts.pending and draws with a stand-in; a resolver that throws reports the family missing with its error.

      Parameters

      Returns void

    • Sets the face for characters no other font has, after the character-fallback families: 'bundled' (the bundled symbol font, the default), 'off', or a font's bytes or URL, whose first face draws them. It is never a family a document can name. Rejects with invalidArgument for bytes holding no face, leaving the setting as it was.

      Parameters

      • font: string | Uint8Array<ArrayBufferLike> | URL

      Returns Promise<void>