Skip to content

feat(fonts): optional @superdoc/fonts package for bundled fonts (SD-3441)#3728

Closed
caio-pizzol wants to merge 3 commits into
mainfrom
feat/superdoc-fonts-package
Closed

feat(fonts): optional @superdoc/fonts package for bundled fonts (SD-3441)#3728
caio-pizzol wants to merge 3 commits into
mainfrom
feat/superdoc-fonts-package

Conversation

@caio-pizzol

Copy link
Copy Markdown
Contributor

Installing SuperDoc from npm puts the bundled fallback fonts in node_modules but 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/fonts is an optional package whose asset URLs are new URL('../assets/x.woff2', import.meta.url) literals, so the consumer's bundler emits and serves the .woff2 from one line, fonts: superdocFonts. It uses the existing fonts.resolveAssetUrl hook, so there is no SuperDoc public API change.

  • Makes the bundled-font load failure log one actionable warning (install @superdoc/fonts, or set fonts.assetBaseUrl / resolveAssetUrl).
  • Documents the setup in getting-started/fonts and wires the framework getting-started examples.
  • Needs a manual first publish: @superdoc/fonts@0.1.0 is not yet in release automation. Publish it to the @superdoc org (steps in packages/fonts/RELEASING.md) before the examples can move off workspace:*.
  • Toolbar honesty (don't advertise fonts that won't render) is a tracked follow-up.

Verified: a production vite build of an npm consumer (superdoc@1.40.0 + @superdoc/fonts, no public/fonts) emits all 65 woff2 to dist/assets; the served build loads them 200 and Baskerville renders Bacasime Antique; clean-checkout tsc, pnpm install --frozen-lockfile, and git diff --check pass.

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.
@caio-pizzol caio-pizzol requested a review from a team as a code owner June 12, 2026 21:56
@linear-code

linear-code Bot commented Jun 12, 2026

Copy link
Copy Markdown

SD-3441

@github-actions

Copy link
Copy Markdown
Contributor

@codecov-commenter

Copy link
Copy Markdown

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants