feat(fonts): optional @superdoc/fonts package for bundled fonts (SD-3441)#3728
Closed
caio-pizzol wants to merge 3 commits into
Closed
feat(fonts): optional @superdoc/fonts package for bundled fonts (SD-3441)#3728caio-pizzol wants to merge 3 commits into
caio-pizzol wants to merge 3 commits into
Conversation
When the bundled substitute .woff2 are not served (the common npm/bundler case), route the load failure to one clear, one-time warning that names the fix: install @superdoc/fonts, or set fonts.assetBaseUrl / resolveAssetUrl. Matches by physical family name (not provenance), so it covers the bundled pack without nagging on customer fonts. Adds registry tests for the routing.
Ship the bundled metric-compatible substitutes as a separate, optional package whose asset URLs are new URL(import.meta.url) literals, so a consumer's bundler emits and serves the .woff2 with no copy step and no assetBaseUrl. It wires through the existing fonts.resolveAssetUrl hook, so superdoc core is unchanged. Binaries stay sourced from shared/font-system/assets (synced at prepare; the assets dir is gitignored). The generated asset-urls.ts is committed and Prettier-stable, so the package typechecks from a clean checkout and the build stays idempotent. Document the setup in getting-started/fonts, note the manual first publish in RELEASING.md, and wire the framework getting-started examples.
Contributor
|
📖 Docs preview: https://superdoc-feat-superdoc-fonts-package.mintlify.app |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…EADMEs Add @superdoc/fonts to the quickstart and framework-guide basic setup (install line + first render only), and note font serving in the examples, CDN, and Laravel READMEs. Keeps the detail on the Font support page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Installing SuperDoc from npm puts the bundled fallback fonts in
node_modulesbut does not serve them to the browser, so an unconfigured Vite/Next app 404s the substitutes and a font like Baskerville falls back to its logical name (only correct on a machine that already has it).@superdoc/fontsis an optional package whose asset URLs arenew URL('../assets/x.woff2', import.meta.url)literals, so the consumer's bundler emits and serves the.woff2from one line,fonts: superdocFonts. It uses the existingfonts.resolveAssetUrlhook, so there is no SuperDoc public API change.@superdoc/fonts, or setfonts.assetBaseUrl/resolveAssetUrl).@superdoc/fonts@0.1.0is not yet in release automation. Publish it to the@superdocorg (steps inpackages/fonts/RELEASING.md) before the examples can move offworkspace:*.Verified: a production
vite buildof an npm consumer (superdoc@1.40.0+@superdoc/fonts, nopublic/fonts) emits all 65 woff2 todist/assets; the served build loads them 200 and Baskerville renders Bacasime Antique; clean-checkouttsc,pnpm install --frozen-lockfile, andgit diff --checkpass.