Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

refactor: drop remote Inter fallback, Inter is bundled too

Sidwebworks5ba9fc09cbee
diff --git a/.claude/rules/pdf-generation-patterns.md b/.claude/rules/pdf-generation-patterns.md
index fa72c7c5d3..eee9342d21 100644
--- a/.claude/rules/pdf-generation-patterns.md
+++ b/.claude/rules/pdf-generation-patterns.md
@@ -32,8 +32,8 @@ All PDF components are barrel-exported from `pdf/index.ts`.
## Shared chrome & components (`pdf/components/`)
- **`Template.tsx`** — the page shell every full-page doc wraps. Renders
- `<Document><Page size="A4">` with body padding, registers **Inter** statically,
- picks a safe `fontFamily` (falls back to Helvetica if unregistered), and mounts
+ `<Document><Page size="A4">` with body padding, resolves the body font via
+ `getSafeFontFamily` (falls back to Helvetica if unregistered), and mounts
the fixed `<Footer>` + repeating `headerContent`. Props include `title`, `meta`,
`theme`, `showFooter`, `showPageNumbers`, `pageNumberFormat`, `fontFamily`. It
wraps children in `DocStyleProvider` so blocks read the themed `tw`.
@@ -119,8 +119,9 @@ Times-Roman / Courier are PDF built-ins (no registration).
Same pattern as the gitignored Lingui `.mjs`. Run `pnpm --filter @carbon/documents
build` manually to refresh after changing the family list.
- `registerDocumentFonts()` — idempotent, synchronous; registers every bundled
- family from local woff. If Inter isn't bundled yet (pre-generation), it falls back
- to remote Inter TTF URLs so the default still renders.
+ family (including the default, Inter) from local woff. No network. If the data is
+ empty (generator never ran), every family degrades to Helvetica via
+ `getSafeFontFamily` — no crash.
- `ensureFont(family)` — back-compat async wrapper (routes still `await` it); just
calls `registerDocumentFonts()`. The `family` arg is ignored (all registered up front).
- `getSafeFontFamily(family)` — returns the family if built-in/registered, else
diff --git a/packages/documents/src/pdf/fonts.ts b/packages/documents/src/pdf/fonts.ts
index 00a870d7b8..f7662460e2 100644
--- a/packages/documents/src/pdf/fonts.ts
+++ b/packages/documents/src/pdf/fonts.ts
@@ -9,32 +9,6 @@ import { BUNDLED_FONTS } from "./fonts.data";
export const BUILT_IN_FONTS = ["Helvetica", "Times-Roman", "Courier"];
-// Used only before fonts.data.ts is generated, so the default still renders.
-const INTER_URL_FALLBACK = {
- family: "Inter",
- fonts: [
- {
- src: "https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfMZhrib2Bg-4.ttf"
- },
- {
- src: "https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuOKfMZhrib2Bg-4.ttf",
- fontWeight: 300
- },
- {
- src: "https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuI6fMZhrib2Bg-4.ttf",
- fontWeight: 500
- },
- {
- src: "https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuFuYMZhrib2Bg-4.ttf",
- fontWeight: 700
- },
- {
- src: "https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuBWYMZhrib2Bg-4.ttf",
- fontWeight: 900
- }
- ]
-};
-
let registered = false;
export function registerDocumentFonts(): void {
@@ -44,9 +18,6 @@ export function registerDocumentFonts(): void {
for (const { family, fonts } of BUNDLED_FONTS) {
Font.register({ family, fonts });
}
- if (!BUNDLED_FONTS.some((f) => f.family === "Inter")) {
- Font.register(INTER_URL_FALLBACK);
- }
}
// Back-compat: routes await ensureFont(family) before render, but fonts are now all