ThorVG WebCanvas API - v1.1.4
    Preparing search index...

    Interface FontProvider

    Interface for pluggable font sources.

    A font provider resolves a font name into binary font data. Implement this interface to load fonts from any source — a self-hosted CDN, a local server, or any custom storage.

    TVG.Font.provider({
    fetch: async (name) => {
    const res = await fetch(`/my-fonts/${name}.ttf`);
    return { data: new Uint8Array(await res.arrayBuffer()), type: 'ttf' };
    }
    });

    await TVG.Font.load('my-font');
    interface FontProvider {
        fetch(
            name: string,
            options?: Record<string, unknown>,
        ): Promise<FontProviderResult>;
    }

    Implemented by

    Index
    • Fetch font data by name.

      Parameters

      • name: string

        Font name as provided by the caller

      • Optionaloptions: Record<string, unknown>

        Provider-specific options

      Returns Promise<FontProviderResult>

      Font binary data and format