webcanvas: added FontProvider for pluggable font backends#256
Conversation
ef694fe to
e7abb9d
Compare
e7abb9d to
2493a24
Compare
|
🚀 Playground preview deployment ready! 🎮 Playground: https://thorvg-playground-hw4nonix9-thorvg-web.vercel.app |
|
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a pluggable FontProvider abstraction for @thorvg/webcanvas so Font.load() can auto-fetch font binaries via a configurable backend (defaulting to a new FontsourceProvider), and removes the old FontRegistry-based tracking.
Changes:
- Added
FontProvider/FontProviderResultinterfaces and a defaultFontsourceProviderimplementation. - Added
Font.setProvider()and updatedFont.load(name, options?)to use the configured provider (options now vendor-agnostic). - Updated package exports/types accordingly and removed the old
FontRegistryutility.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/webcanvas/src/utils/FontRegistry.ts | Removed previous fontsource-fetch dedup/registry helper. |
| packages/webcanvas/src/core/FontProvider.ts | Added provider interface for pluggable font fetching backends. |
| packages/webcanvas/src/providers/FontsourceProvider.ts | Added default provider that fetches fonts from the fontsource CDN. |
| packages/webcanvas/src/core/Font.ts | Switched Font.load() to provider-based fetching and added Font.setProvider(). |
| packages/webcanvas/src/index.ts | Exported the new provider/types and re-exported FontsourceOptions from the provider module. |
| packages/webcanvas/src/core/Text.ts | Minor JSDoc update for Text.font(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2493a24 to
1028316
Compare
|
🚀 Playground preview deployment ready! 🎮 Playground: https://thorvg-playground-riha4e015-thorvg-web.vercel.app |
|
@tinyjin Please arrange the apis and then let's push this. |
1028316 to
ea16259
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a pluggable FontProvider abstraction for @thorvg/webcanvas so Font.load(name, options?) can auto-fetch font binaries via a configurable backend (defaulting to a new FontsourceProvider), and removes the old FontRegistry tracking.
Changes:
- Added
FontProvider/FontProviderResulttypes and a defaultFontsourceProviderimplementation. - Updated
Font.load(name, options?)to delegate font fetching to the configured provider and decoupledoptionsfrom the fontsource-specific type. - Updated public exports to expose
FontsourceProvider,FontsourceOptions, and the provider interfaces.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/webcanvas/src/utils/FontRegistry.ts | Removed prior fetch-state dedup helper used for fontsource auto-loading. |
| packages/webcanvas/src/providers/FontsourceProvider.ts | Added default provider that fetches .ttf files from the fontsource CDN. |
| packages/webcanvas/src/core/FontProvider.ts | Added provider interface + result type for pluggable font sources. |
| packages/webcanvas/src/core/Font.ts | Switched auto-load logic to use the provider abstraction and added caching/dedup state. |
| packages/webcanvas/src/core/Text.ts | Updated Text.font() JSDoc wording. |
| packages/webcanvas/src/index.ts | Exported the provider class and related public types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🚀 Playground preview deployment ready! 🎮 Playground: https://thorvg-playground-ms8jnwx8k-thorvg-web.vercel.app |
API addtion & modification
Example
issue: #242