FontConfig>= v1.0.26
FontConfig:
{}Font configuration for the Document Authoring system.
The font system supports three approaches:
DefaultFontIndex: Built-in fonts (included by default)FontFile: Individual font files loaded upfrontFontIndex: Efficient lazy-loading from a font index
Examples
Section titled “Examples”
fontConfig: { fonts: [ { type: 'file', blob: fetch('/fonts/custom-font.ttf') }, { type: 'file', blob: fetch('/fonts/another-font.ttf') }, ], },});// Step 1: Generate font index using CLI// $ npx document-authoring create-font-index --scan-directory ./fonts --write-to public/fonts/font-index.json
// Step 2: Configure system to use the index
fontConfig: { fonts: [ { type: 'index', index: fetch('/fonts/font-index.json'), loadFn: (name) => fetch(`/fonts/${name}`), }, ], },});
// Fonts from the index are loaded on-demand as documents use them
// Configure font sources fontConfig: { fonts: [ { type: 'index', index: fetch('/fonts/corporate-fonts.json'), loadFn: (name) => fetch(`/fonts/${name}`), }, ], },});
// Import a DOCX that uses custom fontsconst doc = await system.importDOCX(fetch('/template.docx'));// System automatically loads required fonts from the index
// Create editor with the documentconst editor = await system.createEditor(targetElement, { document: doc });// Users can now select from all available fonts in the UICreateDocAuthSystemOptionsfor all available options when creating a DocAuthSystem.FontFilefor loading individual fonts.FontIndexfor efficient font loading.DefaultFontIndexfor built-in fonts.
Properties
Section titled “Properties”fonts?
Section titled “fonts?”
optionalfonts: (DefaultFontIndex|FontIndex|FontFile)[]
The set of fonts available to the Document Authoring system. If unset the DefaultFontIndex is used.
Individual fonts can be added directly using a FontFile or loaded by the system as they are needed using a pre-built
FontIndex that lists all available fonts. A FontIndex is the recommended way to provide a set of fonts to the system in a
production environment.