Loads fonts outside a viewer — for a font picker of your own, or to check what a font covers. A viewer builds its own registry from fonts; one you construct is never seen by a viewer. No member needs a license feature or a document.
The catalog is BUILTIN_FONTS plus what you registered, as FontDefinitions: { id, displayName, category, source, cssFallback, ttfPath?, ttfUrl?, ttfBytes? }, where category is 'sans-serif' | 'serif' | 'monospace' | 'display', source is 'standard' | 'bundled' | 'custom', cssFallback the CSS font-family stack for previews, ttfPath the file name under fonts.fontsBaseUrl (self-hosting), and ttfUrl / ttfBytes set for custom fonts.
classnew FontRegistry(fontsConfig?)
Usage
TypeScript
import { FontRegistry } from'@kernstra/pdf-web-sdk';
const fonts = newFontRegistry(fontsConfig); // optional: the same FontsConfig a viewer takes
fonts.registerCustomFontUrl({ id: 'brand', displayName: 'Brand Sans', ttfUrl: '/fonts/brand.ttf' });
for (const font of fonts.getAll()) {
picker.add(newOption(font.displayName, font.id));
}
fonts.destroy();
Constructor
newFontRegistry(config?: FontsConfig)
Constructing one with fontsBaseUrl under a license without self-hosting throws FEATURE_NOT_LICENSED.
{ id, displayName, ttfBytes, category?, cssFallback? } — the same bag as a fonts.customFonts entry. category defaults to 'sans-serif'; cssFallback to the display name, then sans-serif.