Skip to content

webcanvas: abstract font fetching behind FontProvider interface #242

@tinyjin

Description

@tinyjin

Related to this, we're currently implementing font auto-loading so users can call Font.load() without supplying raw font data.

Since the font backend may change over time, abstracting it behind a FontProvider interface decouples us from any specific external service.

Image

The interface could also be opened up for users to supply custom providers in the future:

TVG.Font.setProvider({
  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-custom-font');

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions