webcanvas: added FontProvider for pluggable font backends#256
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 |
API addtion & modification
Example
issue: #242