Type Alias FontIndex

FontIndex: {
    type: "index";
    index: BlobInput;
    loadFn: ((name: string) => BlobInput);
}

A FontIndex is the preferred way to add additional fonts to the system.

Document Authoring can efficiently load a single index of available fonts, and will then only load the actually required fonts as they are needed by calling loadFn with the font name. loadFn must return a BlobInput for the font file requested.

In order to generate a font index from a set of fonts you want to provide to your users, use the Document Authoring CLI utility:

npx document-authoring create-font-index --scan-directory path-to-fonts --write-to font-index.json

This will generate a font-index.json file that you can then host and load using the FontIndex configuration.

{
type: 'index',
index: fetch('/fonts/font-index.json'),
loadFn: (name) => fetch(`/fonts/${name}`),
}